I’m trying to make an obby system that spawns you at a different spawn depending on your leaderstats aka stage number on the side. I’ve tried many videos on youtube and searched on here a couple times and haven’t really seen anything. The main reason I want it to be based on leaderstats is so that it’ll be easier to work with skip stages and other things like that. The only skip stage thing that might work but is a big hassle is to input all the coordinates and tp them based on that. I made a simple script to constantly check what your leaderstats value is.
local a = 1
local kill = 0
local player1 = game.Players.LocalPlayer
while a == 1 do
if player1:WaitForChild("leaderstats"):WaitForChild("Stage") == script.Parent.Name then
kill = 1
a = 2
player1.Character.Humanoid.HumanoidRootPart.CFrame = game.Workspace.Finish.CFrame.Vector3.new(script.Parent.CFrame.X, script.Parent.CFrame.Y, script.Parent.CFrame.Z)
end
end
if kill == 1 then
player1.Character.Humanoid.Health = 0
kill = 0
end
I’m unsure what else to do to make sure it will work. I’d also like to find a way to make sure it doesn’t kill the person if they touch it only if they buy a skip stage, but I can probably find a way to do that, I just need help with the whole spawning part.
Thanks, I’m still a really new scripter but I’m trying to figure it out as I go based on tutorials that aren’t exactly about the same subject but I still pick up on it a bit. Anyways, you don’t happen to know how to teleport the player, I thought that line would do it but it isn’t atleast from what I’ve tried.
I’ve added prints because it doesn’t seem to be working and then looking in the output it never printed anything, so there’s something wrong with the first part but I’m not sure what it is, I’ve double checked to make sure it’s “Stage”, but I’m also using someone else’s script for the checkpoint handler, so it could be interfering with it somehow, and all the checkpoints are named 1, 2, 3, etc so it shoud work with the script.Parent.Name, but I don’t know lemme know if there’s anything you know of that’s wrong.
What I’ve done so far is:
local a = 1
local kill = 0
local player1 = game.Players.LocalPlayer
while a == 1 do
if player1:WaitForChild("leaderstats"):WaitForChild("Stage") == script.Parent.Name then
print("a")
kill = 1
a = 2
player1.Character.Humanoid.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.Finish.CFrame.p, Vector3.new(script.Parent.CFrame.p.X, script.Parent.CFrame.p.Y, script.Parent.CFrame.p.Z))
print("b")
end
end
if kill == 1 then
wait(1)
print("c")
player1.Character.Humanoid.Health = 0
kill = 0
end
I had .Value before it’s just I removed it for a second to check and forgot to add it back, but anyways I added it back and currently it still doesn’t work.
Not sure what is wrong with it, I’m using the value not the name.
This is kinda annoying because all I’m trying to do is a fairly simple script to work with a skip stage dev product. The dev product part is in a different script though.
BIG thing. Your infinite while true do loop doesn’t have a wait(). It NEEDS a wait, otherwise the script will crash because you are trying to run it instantly as well as infinitely. Between your 1st and 2nd end, put “wait()”.
Tried to get a video recording of me buying it and nothing happening after my Stage value turned to 2, but devforum doesn’t allow the file that the default recorder records in.
Why do you have a conditional loop to check if the value is equal to the parent name? You can use the Value.Changed event which returns the new value after the change.
Stage.Changed:Connect(function(newValue)
if newValue == script.Parent.Name then
--tp here
end
end)
I know I’m probably going to look stupid, but hey this is my first actual script. Not sure what exactly is wrong with my script, it yells at me for no having a then, then when I put a “then” it yells at me for not putting ) and wherever I put that nothing happens.
local player1 = game.Players.LocalPlayer
local a = 1
while a == 1 do
if player1:WaitForChild("leaderstats").Stage.Changed:Connect(function(newValue)
print("a")
if newValue == script.Parent.Name then
player1.Character.Humanoid.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.Finish.CFrame, Vector3.new(script.Parent.CFrame.X, script.Parent.CFrame.Y, script.Parent.CFrame.Z)) --tp here
end
wait(0.5)
end)
end
(Not in the right tabbing over because it didn’t want to work for me on the site but it is fine on the actual script)
Sorry again, since this is probably super obvious.