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

5 comments
Try player:WaitForChild("PlayerGui")
for what line?
local pow = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("PowerGui2"):WaitForChild("Frame")
Thanks
mouse.KeyDown should not be used. Use UserInputService instead. Make sure that this is done in a local script.