local Checkpoints = game.Workspace.Game.Obby.Checkpoints
local Debounce = false
local Players = game:GetService("Players").LocalPlayer
for index, value in pairs(Checkpoints:GetChildren()) do
if value.Touched:Connect(function(part)
--StageEvent:FireServer()
local partParent = part.Parent
local player = game.Players:GetPlayerFromCharacter(partParent)
local leaderstats = player.leaderstats
local playerStage = leaderstats.Stage
local playerPoints = leaderstats.Points
if tonumber(value.Name) == playerStage.Value + 1 then
if not Debounce then
Debounce = true
print("WHAT IS THIS SORCERY?")
--value.BrickColor = BrickColor.new(0,255,0)
playerStage.Value = playerStage.Value + 1
playerPoints.Value = playerPoints.Value + 5
wait()
Debounce = false
if part:IsDescendantOf(player.Character) then
value.BrickColor = BrickColor.new(0,255,0)
end
if player.MembershipType == Enum.MembershipType.Premium then
print("Premium you get +5 points!")
-- Take some action specifically for Premium members
playerPoints.Value = playerPoints.Value + 5
else
print("Non premium you just get + 5")
end
end
end
end) then
end
end
Thank you works just how I want it to!
I was using localplayer for leaderstats earlier lol then realized why it wasn’t working properly. I seperated both now thanks again!
This is the adapted code I used (in a localscript, under StarterPlayerScripts):
local Checkpoints = game.Workspace.Checkpoints
local Debounce = false
for index, value in pairs(Checkpoints:GetChildren()) do
if value.Touched:Connect(function(part)
local partParent = part.Parent
local player = game.Players:GetPlayerFromCharacter(partParent)
local leaderstats = player.leaderstats
local playerStage = leaderstats.Stage
local playerPoints = leaderstats.Points
if tonumber(value.Name) == playerStage.Value + 1 then
if not Debounce then
Debounce = true
print("Working checkpoint!")
--value.BrickColor = BrickColor.new(0,255,0)
playerStage.Value = playerStage.Value + 1
playerPoints.Value = playerPoints.Value + 5
wait()
Debounce = false
if player and part:IsDescendantOf(game.Players.LocalPlayer.Character) then
value.BrickColor = BrickColor.new(0,255,0)
end
if player.MembershipType == Enum.MembershipType.Premium then
print("Premium you get +5 points!")
-- Take some action specifically for Premium members
playerPoints.Value = playerPoints.Value + 5
else
print("Non premium you just get + 5")
end
end
end
end) then
end
end