local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local part = Instance.new("Part")
part.Name = player.Name.."Part"
part.Parent = workspace
local object = Instance.new("ObjectValue")
object.Name = player.Name.."Value"
object.Parent = part
object.Value = character
local money = Instance.new("IntValue")
money.Name = "Money"
money.Parent = part
money.Value = 100
end)
player.CharacterRemoving:Connect(function(character)
workspace:FindFirstChild(player.Name.."Part"):Destroy()
end)
script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChild(player.Name.."Value") then
local ls = player.leaderstats
local money = ls.Money
money.Value += hit.Money.Value
end
end)
end)
This will need to be changed slightly to fit your purposes.
I understand it has been a long time since this post was originally made but I may have seemed to have found a solution.
Server script:
script.Parent.Touched:Connect(function(Hit)
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player then
Player.leaderstats.Money.Value += 10 -- You can replace the number 10 with whatever value you want to reward the player with
end
end)
Wow… almost 2 years since this was posted.
I dont think OP still need the answer. Your reply is more like the “mandatory procedure” to follow for a touch event, maybe it was not needed to rebump this, but yeah why not