Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local stardestroy = ReplicatedStorage:WaitForChild("StarDestroyCondition")
local RunService = game:GetService("RunService")
game.Players.PlayerAdded:Connect(function(player)
while true do
wait()
local Levels = player:WaitForChild("leaderstats").Level.Value
local LevelString = script.Parent.Parent.StarterPlayer.StarterPlayerScripts.LocalArrowScript.Levels.Value
print("String Obtained", LevelString, "and Levels Obtained", Levels)
if tonumber(Levels) == 5 then
if Levels == LevelString then
stardestroy:FireClient(player)
print("Fired Successfully")
end
end
end
end)
Any idea on how I could brush up this script to be able to determine the amount of checkpoints automatically without me having to change the value each time??
Specifically this piece of coding, I want to change it in order for it to become automatic.
if tonumber(Levels) == 5 then
The thing is, this piece of coding is supposed to fire a remote event to the client side which will, in return, trigger this piece of coding on a local script:
StarDestroyer.OnClientEvent:Connect(function()
cloneStar:Destroy()
print("Destroyed")
end)
But in order for that to happen and work, I need the LevelString to contain the amount of checkpoints that my game possesses and if I add any more checkpoints, I would like it to be updated automatically.

1 comment
??