Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my GUI not changing from a script? It should be saying yes or yo when I press a button.

Asked by 6 years ago
Edited 6 years ago

Here is the localscript on a ScreenGui object, wordDis is also a child of ScreenGUI. `` function displayWord(key)

if(key == Enum.KeyCode.R) then
    script.Parent.wordDis.Text = "yes"
end

if(key == Enum.KeyCode.F) then  

    script.Parent.ScreenGUI.wordDis.Text = "yo"
end


end



game:GetService("UserInputService").InputBegan:connect(displayWord)
0
I am still figuring out how to use the formatting on here XD WorkAtChickenPlace 19 — 6y
0
What does the output say? Also, do not use brackets on the "IF" statements. marketmanager1 52 — 6y

1 answer

Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
6 years ago

key is not actually the keycode. key is actually an InputObject. To get the KeyCode, you must use key.KeyCode instead.

Source

0
thank you so much, I have been trying to get this for about an hour now and finally resorted to use this website. I'm glad I did. :) WorkAtChickenPlace 19 — 6y
0
No problem. xAtom_ik 574 — 6y
Ad

Answer this question