Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"attempt to index local 'Player' (a nil value)" How to fix this error?

Asked by 8 years ago
game.Workspace.CaseD.Touched:connect(function(User)
wait(.5)
if User.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(User.Parent)
if Player.TeamColor == "Bright bluish green" and KF.Value == false then
KF.Value = true
script.Parent.ServerEffects.Flag:Clone().Parent = User.Parent.Head
end
end
end)

14:04:35.247 - Workspace.ServerScripts.MasterScript:42: attempt to index local 'Player' (a nil value) 14:04:35.248 - Stack Begin 14:04:35.249 - Script 'Workspace.ServerScripts.MasterScript', Line 42 14:04:35.249 - Stack End

1 answer

Log in to vote
0
Answered by
Etheroit 178
8 years ago
Edited 8 years ago

check isnt Player nil. TeamColor is a brickcolor, not string.

game.Workspace.CaseD.Touched:connect(function(User)
wait(.5)
if User.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(User.Parent)
if Player ~= nil then
if Player.TeamColor == BrickColor.new("Bright bluish green") and KF.Value == false then
KF.Value = true
script.Parent.ServerEffects.Flag:Clone().Parent = User.Parent.Head
end
end
end
end)

EDIT: Try now

0
But now if the player has the right team and the value is false he doesnt get the effect. iiEpixnesss 0 — 8y
1
TeamColor is a BrickColor value, not a string BlueTaslem 18071 — 8y
0
Oh yeah. Didnt see it :/ Etheroit 178 — 8y
Ad

Answer this question