How can I fix attempt to index nil with 'Character'

Hi,
I want to make a tool and if the player clicks it should make the jumppower to 0 and the walkspeed to 0 but in the output it says attempt to index nil with Character.
here is the script:

local Player=game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.Button1Down:Connect(function(player)
	local character = player.Character
	if not character then return end
	character.Humanoid.WalkSpeed = 0
	character.Humanoid.JumpPower = 0
end)

any help is appreciated

uuhhh Mouse.Button1Down doesn’t use arguments, please use the old Player variable you created, like this

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.Button1Down:Connect(function()
	local character = Player.Character
	if not character then return end
	character.Humanoid.WalkSpeed = 0
	character.Humanoid.JumpPower = 0
end)
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.