-
What do you want to achieve? Keep it simple and clear!
I want to make a skip-stage script for my Obby.
-
What is the issue? Include screenshots / videos if possible!
For the checkpoints, I used a script that I copied from a youtube video, I now want to make a skip-stage button, but since I’m very bad at scripting I have no idea how to make it. Could someone help me?
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked on youtube for skip-stage scripts and copied a few, but they all don’t seem to work with the checkpoint script I use.
Could someone please help me with this skip-stage script? I already got the GUI ready, I only need a script that performs when a player clicks on “yes”. I think it should teleport the player to the next checkpoint, or add 1 to the leaderboard stats and kill the player so he/she spawns at that checkpoint.
2 Likes
I used this script for the checkpoint system:
‘’’
local STAT_NAME = “Stage”
local PREVENT_SKIPPING = true
local checkpoints = {}
local i = 1
while true do
local checkpoint = Workspace:FindFirstChild("Checkpoint " … i, true)
if not checkpoint then print("Last Checkpoint : " … i-1) break end
table.insert(checkpoints, checkpoint)
i = i + 1
end
game.Players.PlayerAdded:connect(function(player)
local leaderstats = player:FindFirstChild(“leaderstats”) or Instance.new(“Model”, player)
leaderstats.Name = “leaderstats”
local checkpointStat = Instance.new("IntValue", leaderstats)
checkpointStat.Name = STAT_NAME
checkpointStat.Value = 1
player.CharacterAdded:connect(function(character)
local goto = checkpoints[checkpointStat.Value]
if goto then
repeat wait() until character.Parent
character:MoveTo(goto.Position)
else
warn("Checkpoint " .. checkpointStat.Value .. " not found")
end
end)
end)
for index, checkpoint in ipairs(checkpoints) do
checkpoint.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player then return end
local humanoid = hit.Parent:FindFirstChild(“Humanoid”)
if not humanoid or humanoid.Health <= 0 then return end
local leaderstats = player:FindFirstChild(“leaderstats”)
if not leaderstats then return end
local checkpointStat = leaderstats:FindFirstChild(STAT_NAME)
if not leaderstats then return end
if (PREVENT_SKIPPING and checkpointStat.Value + 1 == index) or (not PREVENT_SKIPPING and checkpointStat.Value < index) then
checkpointStat.Value = index
end
end)
end
‘’’
I can help but im on cp now i hope there is one here will help u
2 Likes
here:
script.Parent.TextButton.MouseButton1Click:Connect(function() -- function
local plr = game.Players.LocalPlayer -- your player
plr.Character.Humanoid.CFrame = game.Workspace.Baseplate.next.CFrame -- your checkpoint
end)
note: this is the base script not the finished script.
Hey, thanks for your response, the problem is, I don’t know much about scripting. What should I do with this base script?
1 Like
Hello
I Am TheoDev in DevFurom
also in RoDevs
Make a Script in ServerScriptService
and put this
MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
local players = game.Players:GetPlayers()
local currency = "Stage"
local done = 0
for i = 1,#players do
if players[i].userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == 978487374 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
make a gui button in ScreenGui add local script and put this
local productId = 978487374 -- Change to the ID of your developer product.
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
5 Likes
Wow! Okay thx! I’ll give you credit for the skip-stage-button
Now I can finally continue working on my obby!
1 Like
Welcome I am currently working on obby too!
Oh that’s cool! Btw, I don’t know if it is much work, but how would I make the skip-stage thing free, without a gamepass? Could you help me with that please?
1 Like
ow u want free skipstage but the player will just click the skipstage and not gonna play it fair
Yes I know, but people who really want to play it only use it when a stage is really too hard. I don’t want to make a very big surprise at the end so there isn’t really a goal just skipping al stages. And I don’t want people to stop playing the game because 1 stage is too hard.
An easier approach would just make it so that when you click a button, teleport them to the next checkpoint, causing the checkpoint system to update their checkpoint.
Considering from what you mentioned, you don’t understand scripting all that well, so I would use what OverDayLight said which is the exact system I just reccomended.
You would need to assign what the object next is.
If you need help with this, just ask.
Hey, thanks for your reply. You are right, I am indeed not very good at scripting, I am watching TheDevKings videos and try to get better over time. Do I need to make Tables for that script? I don’t really know how to make it. I would really appreciate your help!
You shouldn’t need tables.
A easier way than setting next would probably be if that next next checkpoint script is local (which it probably should be considering its a script on a GUI), set up a RemoteEvent to up the players checkpoint value when it is fired and set their health to 0 to make them spawn at their new checkpoint.
You can call a RemoteEvent using RemoteEventName:FireServer(plr). This only works on LocalScripts.
LocalScript on any GUI Button:
script.Parent.TextButton.MouseButton1Click:Connect(function() -- function
local plr = game.Players.LocalPlayer -- your player
YourRemoteEventInstance:FireServer(plr)
-- Note that "YourRemoteEventInstance" will be wherever you put the RemoteEvent.
-- For example: game.Workspace.RemoteEvent, I reccomend ReplicatedStorage
-- for RemoteEvents.
end)
Server Script under a RemoteEvent:
script.Parent.OnServerEvent:Connect(function(plr)
plr.Character.Humanoid
end)
This is the unfinished script, use here for Humanoid reference to find how to set Health, and then look at your checkpoint script to figure out how to set the value to + 1.
(These are untested, tell me if it doesn’t work)
Does it need a datastore? If it’s then ill make you the whole script!
30 Minutes to 1 hour.
Looking at his script, I think it was using leaderboard for the value.
EDIT:
or an IntegerValue, I am not sure
@epicduck410 Its not using leaderstats datastore…
1 Like
Hey, that would be amazing, thanks for the offer! Could you do that for me? You will receive credit in my game for making the script!
Hey, thank you really much for your help, I tried it but I can’t really figure out what to put under the RemoteEvents script. I don’t know how to set the value 1 up, should I use i, v in pairs or something else from the checkpoint script? Could you please type it out for me?
Not 100% on how your script works, but when I looked at it, I was thinking this might work.
EDIT:
This will go under your script for when the RemoteEvent fires
checkpointStat = plr.leaderstats.Stage
checkpointStat.Value = checkpointStat.Value + 1
From the looks of it, this value is under plr.leaderstats.STAT_NAME which is another variable apparently, so I added that in. Correct it if I am wrong.
If you still prefer the system of teleporting to the next checkpoint, we can do that, but this system is way simpler, and most obbies use it.