this script is to pick up a coin and to add a point on the leader stats but it won't let me add the points to the leader stats.
local coin = script.Parent function ont(hit) if hit.Parent:FindFirstChild("Humanoid") then Points.Value = Points.Value + 1 coin:Destroy() end end game.Workspace.Part.Touched:connect(ont)
Use Script and put into the part u want to collect
local coin = script.Parent function ont(hit) if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then local Points = plr:FindFirstChild("leaderstats").Points Points.Value = Points.Value + 1 coin:Destroy() end end end coin.Touched:Connect(ont)
You never defined Points.
local coin = script.Parent function ont(hit) local player = hit.Parent and game:GetService('Players'):GetPlayerFromCharacter(hit.Parent) local ls = player and player:FindFirstChild('leaderstats') local points = ls and ls:FindFirstChild('Points') if points ~= nil then points.Value = points.Value + 1 coin:Destroy() end end workspace.Part.Touched:connect(ont)
Not sure if anything was defined, give this a shot? Added a debounce so there's a cooldown, feel free to remove this if you please.
local db = false workspace.Part.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = plr:FindFirstChild("leaderstats") if not db then db = true stats.Points.Value = Points.Value + 1 wait(3) db = false end end end)