First off, sorry if there is a way to put the code in a box. I used lines to show where the code starts and ends. I am currently making an obby and I want the person to get money when they step on a checkpoint. I've been trying to figure out the right code but its not working can someone help me. Thanks in Advance
My first code is some code on a script in the ServerScriptService
game.Players.PlayerAdded:connect(function(p)
local touch = Instance.new("IntValue")
touch.Name = "touch"
touch.Parent = p
local level = Instance.new("IntValue")
level.Name = "levelup"
level.Value = 1
level.Parent = touch
end)
My Second code is on the bottom. The other stuff is checkpoint code made by Roblox.
local spawn = script.Parent
spawn.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
if not checkpointData then
checkpointData = Instance.new("Model", game.ServerStorage)
checkpointData.Name = "CheckpointData"
end
local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
if not checkpoint then
checkpoint = Instance.new("ObjectValue", checkpointData)
checkpoint.Name = tostring(player.userId)
player.CharacterAdded:connect(function(character)
wait()
character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
end)
end
checkpoint.Value = spawn
end
spawn.Touched:connect(function(hit2) --This code right here and down
if hit2 and hit2.Parent and hit2.Parent:FindFirstChild("Humanoid") then
if ("levelup") == 1 then
('levelup').Value = ('levelup').Value + 1
("ObbyBucks<|>").Value = ("ObbyBucks<|>").Value + 10
end
end
end)
end)

2 comments
code blocks {PLEASE}
and also, why did you paste the saving data code and not the touch brick code . . .. . .. . misleading title?