I have typed a code that gives you points when you touch it with help from peasfactory
enabled = false
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil and enabled == false then
enabled = true
script.Parent.BrickColor = BrickColor.new("Really red")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local points = player.leaderstats.Points
points.Value = points.Value + 5
wait(3)
enabled = false
script.Parent.BrickColor = BrickColor.new("Sea green")
end
end)
But When I try to change it to a click detector it doesn't work and tells me the player is nil
enabled = false
script.Parent.ClickDetector.MouseClick:Connect(function(click)
local humanoid = click:FindFirstChild("Humanoid")
if humanoid ~= nil and enabled == false then
script.Parent.BrickColor = BrickColor.new("Really red")
enabled = true
local player = game.Players:GetPlayerFromCharacter(click)
local points = player.leaderstats.Points
points.Value = points.Value + 5
wait(3)
enabled = false
script.Parent.BrickColor = BrickColor.new("Sea green")
end
end)

1 comment
Humanoid for the click would be, click.Character.Humanoid