. . . Posted August 3, 2017 Share Posted August 3, 2017 (edited) Hello, if someone can help me with this that'd be great ! So, I want my character based on how I feel would react for some stuffs for his text color to change! I tried this code, but it didn't work? Spoiler local suprised = { "What!?", "AHHAhaHAHAHAHHAhaHAhahAHAhahHAHhahhHahHAhahhhhhhhAHAHAHHAHAHAhhhhhhhhhAHAHAHahAHAHAHAhahahAhahahhhaa!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "Wow!!", "Cool!!?", "Jesus!!!!", } inst.components.talker:Say(suprised[math.random(1,5)], 1, nil, nil, nil, (252/255, 140/255, 118/255)) It crashes saying " ')' expected near ',' " after code reads beyond " inst.components.talker:Say(suprised[math.random(1,5)] " does anyone know the right way I can do this? & thanks for reading my problem, have a wonderful day/night !! Edited August 3, 2017 by SuperDavid Link to comment Share on other sites More sharing options...
Lumina Posted August 3, 2017 Share Posted August 3, 2017 entity.components.talker:Say(not entity:HasTag("mime") and message or "", nil, nil, nil, true, colour) I found this in game code but don't know if it can help. Also, shouldn't be surprised instead of suprised ? Link to comment Share on other sites More sharing options...
JohnWatson Posted August 3, 2017 Share Posted August 3, 2017 Change this: (252/255, 140/255, 118/255) To this: {252/255, 140/255, 118/255, 1} Link to comment Share on other sites More sharing options...
. . . Posted August 3, 2017 Author Share Posted August 3, 2017 Thank you! Now the text changes color in non-dedicated servers & doesn't crash anymore, but the text's color seems to say white in dedicated servers! Is there a way that can be fixed ? And thanks for the help ! Link to comment Share on other sites More sharing options...
ZupaleX Posted August 5, 2017 Share Posted August 5, 2017 (edited) I assume that the way you implement this code made it executed only on the dedicated server side so the client doesn't know the color has been changed. You need somehow to inform your client about that color. As a general rule, if you want the server to inform your client that something changed on a piece of code he doesn't have access to, you need to use a net_variable.There is a stickied post on this forum discussing them. if you want the client to inform the server that something should be changed you need to use a RPC. But then I might be wrong, could you post a bit more about your code? Edited August 5, 2017 by ZupaleX Link to comment Share on other sites More sharing options...
. . . Posted August 5, 2017 Author Share Posted August 5, 2017 Here's the entire code ! MYCHARACTER.lua Spoiler local function Help(inst) --outside of master_postinit local help = { "AJAHAHhaHAhahHAHA", "AHHAahahhhaa!!!!!!!!!!", "LALAshhahhaHHahahahhaahja", "Thats nice", "MYA AGWGWAGWahgjwjWAJwgWG", } inst.components.talker:Say(help[math.random(1,5)], 1, true, nil, nil, {0/255, 255/255, 55/255, 1}) end inst:ListenForEvent("attacked", Help) -- inside master_postinit Link to comment Share on other sites More sharing options...
ZupaleX Posted August 5, 2017 Share Posted August 5, 2017 (edited) master_postinit is server side only, so my guess was correct. Naively I would put it in the common_postinit then? Since this particular component (talker) exists on both the client and the server. That's probably more complicated than that, but that would be my first lazy attempt before looking more into the details ^^ Edited August 5, 2017 by ZupaleX Link to comment Share on other sites More sharing options...
. . . Posted August 5, 2017 Author Share Posted August 5, 2017 So, I put have this code now. Spoiler local function ChangeTextColor(inst, data) --outside of master_postinit local equip = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) if not data.attacker.prefab == "wathgrithr" or (data.attacker.prefab == "wathgrithr" and attacker.equip and not attacker.equip.prefab == "hambat") then return end local quote = { "quote1", "quote2", "quote3", "quote4", "quote5", } inst.components.talker:Say(quote[math.random(1,5)], 1, true, nil, nil, {0/255, 255/255, 55/255, 1}) end local function common_postinit(inst) inst:ListenForEvent("attacked", ChangeTextColor) end I want my character to only this text change when hit by the things I put in the return thing, but it crashes saying "inventory nil" & "attacker" nil. I'm guessing data can't be used in common_postinit or I goofed? Maybe It'd be easier if I just make my own text texture then spawn it as a prefab, hahaha ! Link to comment Share on other sites More sharing options...
ZupaleX Posted August 6, 2017 Share Posted August 6, 2017 Oh it's because these exists only on the server side. Then you need to catch the communication between the server and the client, when the server sned a signal to the client stating "you need to display that", and modify the color at that moment. I can take a look at it if you cannot figure it out Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now