I'm not really sure where to start. Would I use onTouch function?
Place this in the part that you want to be touched:
script.Parent.Touched:connect(function(hit) --When the part is touched. if debounce then return nil end local Player = Game.Players:GetPlayerFromCharacter(hit.Parent) if Player then --If it was a Player that touched. debounce = true Player.leaderstats.Points.Value = Player.leaderstats.Points.Value + 1 wait(1) debounce = false end end)
Simple, really.
function touched(hit) if hit.Parent:findFirstChild("Humanoid") then local plr=game.Players:GetPlayerFromCharacter(hit.Parent) plr.leaderstats.Points.Value=plr.leaderstats.Points.Value+1 end end script.Parent.Touched:connect(touched)
This script will check to make sure it's a person, and then add +1 to points.
Yes. It would look kind of like this.
local function(onTouch) game.Players.PlayerAdded:connect(function(player) Player.leaderstats.Money.Value = Player.leaderstats.Money.Value +1 end
Keep in mind that this is a rough representation, it may/may not work in game.