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

My Keybind TextLabel Script Won't Work. Help please?

Asked by
Aqu_ia 39
6 years ago
01local textlabel = game.StarterGui.ScreenGui.TextLabel
02game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(KeyPressed)
03 
04if KeyPressed == "g" then
05 
06if game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text == "Shii-Cho" then
07 
08game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = "Makashi"
09else
10game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = "Shii-Cho"
11if game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text == "Makashi" then
12 
13game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = "Soresu"
14 
15            end
16        end
17    end
18end)
0
When I first pressed G, it only switches to Makashi, but when I press G again, it switches back to shii-cho, and not to soresu. Aqu_ia 39 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Take a different approach. UserInputService is more appropriate.

01label = game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel
02game:GetService("UserInputService").InputEnded:Connect(function(key)
03if key.KeyCode == Enum.KeyCode.G then
04    if label.Text == "Shii-Cho" then
05        label.Text = "Makashi"
06    elseif label.Text = "Makashi" then
07        label.Text = "Soresu"
08    else
09        label.Text = "Shii-Cho"
10end)
Ad

Answer this question