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

Please can some one help me with this it throws an error?

Asked by 9 years ago

i am trying to make a door when touched it checks the players kills

function GiveGui(Player) if Player.leaderstats.kills >= 1 then script.Parent.Transparency = 1 script.Parent.CanCollide = false wait (0.5) script.Parent.CanCollide = true script.Parent.Transparency = 0 else Player.PlayerGui.Message.TextLabel.Text = "not enough kills" Player.PlayerGui.Message.TextLabel.Visible = true wait (3) Player.PlayerGui.Message.TextLabel.Visible = false
end end

script.Parent.Touched:connect(function(hit)

local Player=game.Players:GetPlayerFromCharacter(hit.Parent) if Player==nil then return end GiveGui(Player)

end)

error:

20:09:20.879 - leaderstats is not a valid member of Player 20:09:20.880 - Script 'Workspace.PaidA.Script', Line 2 - global GiveGui 20:09:20.881 - Script 'Workspace.PaidA.Script', Line 20

2 answers

Log in to vote
0
Answered by 9 years ago

Leaderstats is an entity in game.Players.Player not in the actual Humanoid, you are attempting to get Leaderstats from the Humanoid when there is no Leaderstats in the Humanoid. Therefore, you are receiving the error "leaderstats is not a valid member of Player". Yes, I am obsessed with using "in-line code" wherever I can possibly justify it :p

Ad
Log in to vote
0
Answered by 9 years ago

so how would i fix this

Answer this question