I am having trouble with getting this to work. I tried a remote event, but it gave all players +1
local part = Instance.new("Part"); part.Parent = workspace; part.CFrame = CFrame.new(-685.327, 150.022, 163.614); local enabled = false; part.Touched:connect(function(hit) if game.Players:FindFirstChild(hit.Parent.Name) and game.Players[hit.Parent.Name] == game.Players.LocalPlayer then enabled = true; wait(0.2); part:Destroy(); hit.Parent.leaderstats.Stars.Value = hit.Parent.leaderstats.Stars.Value+1 wait(0.3); enabled = false; end end)
why
I used GetPlayerFromCharacter to be able to access leaderstats, it gets the player from who ever touched the part, and then it adds 1 to stars value, then it destroys the part.
part.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) plr.leaderstats.Stars.Value = plr.leaderstats.Stars.Value + 1 part:Destroy() end end)