So i am making a game but cant get it to work with this script i wrote and dont know why it gives me an nil value.
player = game.Players.LocalPlayer
if not player.leaderstats.mageClass == true then
function Touched()
local humanoid = Touched.Parent:findFirstChild("Humanoid")
if (humanoid ~=nil) then
humanoid.Health = 0
end
end
elseif player.leaderstats.mageClass == true then
local humanoid = Touched.Parent:findFirstChild("Humanoid")
if (humanoid ~=nil) then
humanoid.Health = 100
end
end
script.Parent.Touched:connect(Touched)
11:18:22.691 - Workspace.Model.Part.Script:3: attempt to index global 'player' (a nil value)
11:18:22.691 - Stack Begin
11:18:22.691 - Script 'Workspace.Model.Part.Script', Line 3

4 comments
is this a localscript?
LocalPlayer only works with a Local Script.
oh okay.
If this is fixed pls add [closed] ect to the question title