I have this border script but for some reason once I reach the desired level the border doesn’t open until I rejoin. Does anyone know why?
You’re only checking the value once (when the player joins).
You’ll want to put this in a loop instead, so it checks every few seconds:
while task.wait(3) do
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then -- Only check level if leaderstats exists
if level.Value >= 5 then
...
end
if level.Value >= 10 then
...
end
if level.Value >= 20 then
...
end
end
end
2 Likes
Assuming the local script is in starter player scripts you could do something like this:
local player = game.Players.LocalPlayer
local ls = player:WaitForChild("leaderstats")
local gate1 = workspace.borders:WaitForChild("border1.2")
local gate2 = workspace.borders:WaitForChild("border2.3")
local gate3 = workspace.borders:WaitForChild("border3.4")
local gateLevels = {
[5] = gate1,
[10] = gate2,
[20] = gate3
}
for level, gate in pairs(gateLevels) do
if ls.Level.Value >= level then
gate.CanCollide = false
gate.Transparency = 1
end
end
ls.Level:GetPropertyChangedSignal("Value"):Connect(function()
local unlocked = gateLevels[ls.Level.Value]
if unlocked then
unlocked.CanCollide = false
unlocked.Transparency = 1
end
end)
also if their level can increase by more than 1 at a time, you would need to replace
local unlocked = gateLevels[ls.Level.Value]
if unlocked then
unlocked.CanCollide = false
unlocked.Transparency = 1
end
with
for level, gate in pairs(gateLevels) do
if ls.Level.Value >= level then
gate.CanCollide = false
gate.Transparency = 1
end
end
2 Likes
I hired a scripter for this game and I have very little knowledge about lua. theres no script named leaderstats in the explorer however when I join the game there are leaderstat values. how did he set up the leaderstats do you think?
you could use ctrl+shift+f and search for “leaderstats”, and find what script is setting it up
2 Likes
is it this?
yes
characterlimitcharacterlimitcharacterlimit
1 Like