Hi, I’m currently making a game and I was going to add the ability to skip a stage. I have made the ui for it but my current script doesn’t even let you buy it. I have essentially no knowledge of scripting so I looked on YouTube but from what I gathered they all only work with a different checkpoint script. How would I go about making one?
local v = Instance.new("IntValue")
v.Name = "Stage"
v.Value = 0
v.Parent = leaderstats
plr.CharacterAdded:Connect(function (char)
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
wait()
if hum.Health > 0 then
hrp.CFrame = CFrame.new(workspace.Checkpoints:FindFirstChild("Stage" .. tostring(v.Value)).CFrame.Position + Vector3.new(0, 5, 0))
end
hum.Touched:Connect(function(hit)
if hit.Parent == workspace.Checkpoints then
if hit.Name == "Stage" .. tonumber(v.Value + 1) then
v.Value = v.Value + 1
end
end
end)
end)
In order for this to work you’ll need a local script in the stage part, along with a bindable event in replicated storage and a script in serverscriptservice. The local script will grab the values it needs then sending it to the event. The event will then send it to the server script so it can process the information into what you want.
for i=1,#players do
if players[i].userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == 1085572136 and done == 0 then
done = 1
players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1
players[i].Character.Humanoid.Health = 0
done = 0
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end