I'm trying to make a button that sets the the player's WalkSpeed to 150, what's wrong?
local button = script.Parent local player = game.Players.LocalPlayer --Find Player name local nameofplayer = player.Character.Name--Get the player in workspace botaoz.ClickDetector.MouseClick:connect(function(player) Workspace.Player.Name.Humanoid.WalkSpeed = 150 end
You haven't given any time for the players character to load, also, you didn't put square brackets around the workspace modifier part, and 'Workspace' is deprecated, use 'workspace' instead. Here is the modified script -
local button = script.Parent game.Players.PlayerAdded:Connect(function(player) -- wait for the player to be added player.CharacterAdded:Connect(function(character) -- wait for the character to be added local nameofplayer = player.Name -- get the player in workspace botaoz.ClickDetector.MouseClick:connect(function(player) workspace[nameofplayer].Humanoid.WalkSpeed = 150 --[[ Use the square brackets for referencing--]] end) end) end)