I am trying to make a key press event, and it relies on a GUI in the PlayerGui, but when I try it says "PlayerGui is not a valid member of Player" here is my script:
local pow = game.Players.LocalPlayer.PlayerGui.PowerGui2.Frame -- the GUI local speed = pow.Select1 -- a text button if speed.Text == "Selected" then -- v all the key press stuff v -- m.KeyDown:Connect(function(k) if k == "q" then if db == true then game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 40 db = false wait(10) db = true game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 16 end end end) end
I developed a solution based on Thetcah's comment and here's the answer:
local pow = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("PowerGui2").Frame local speed = pow.Select1 if speed.Text == "Selected" then m.KeyDown:Connect(function(k) if k == "q" then if db == true then game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 40 db = false wait(10) db = true game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 16 end end end) end