When i press S, both the Continue and NewGame buttons turn white. but none of them turns back to the normal color, after you press W
what im trying to do is make a start screen gui that has a new game button and a continue button, that are selected with W (new game) or S(continue)
but when i press any button both of the text color turns white
local frame = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.ImageLabel.Frame.Select
function onKeyPress(inputObject)
if inputObject.KeyCode == Enum.KeyCode.W then
print("W was pressed")
if frame.Position == UDim2.new (0.5, 0,0.559, 0) then
frame.Position = UDim2.new(0.5, 0,0.5, 0)
script.Parent.Parent.Continue.TextColor3 = Color3.new(27, 42, 53)
script.Parent.Parent.NewGame.TextColor3 = Color3.new(255,255,255)
end
elseif inputObject.KeyCode == Enum.KeyCode.S then
print("S was pressed")
if frame.Position == UDim2.new(0.5, 0,0.5, 0) then
frame.Position = UDim2.new(0.5, 0,0.559, 0)
script.Parent.Parent.NewGame.TextColor3 = Color3.new(27, 42, 53)
script.Parent.Parent.Continue.TextColor3 = Color3.new(255,255,255)
end
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
i also tried to put a changed function inside the button
local player = game.Players.LocalPlayer
local frame = player.PlayerGui.ScreenGui.Frame.ImageLabel.Frame.Frame
frame.Position.Changed:connect(function()
if frame.Position == script.Parent.Position then
script.Parent.TextColor3 = Color3.new(255,255,255)
end
end)
Output:
17:28:27.957 - Changed is not a valid member of UDim2

1 comment
tab your code properly.