Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.