Difficulty Chart Obby: How can I reduce this script?

Tell me if there is something you want to be fixed.

1 Like

Wow! Thanks for the scripts. I’m fixing the teleport thing and optimizing it so the names of everything woroks. I’ll get back to you. Thanks again!

2 Likes

Sorry, it’s a bit much to take in. Am I meant to create the teleportedstage value inside the player when they join?

1 Like

Yes, just like I said :slightly_smiling_face:

I don’t understand

	local TeleportedStage = Instance.new("IntValue")
	TeleportedStage.Name = "TeleportedStage"
	TeleportedStage.Parent = player
	TeleportedStage.Value = "0"
	hum.Touched:Connect(function(hit)
			if hit.Parent == checkpoints then
				if tonumber(hit.Name) == player.TeleportedStage.Value + 1 then
					player.TeleportedStage.Value = player.TeleportedStage.Value + 1
                                end
                        end
         end)

When I reload, it still tps me to my stage value. Also, when I use the right and left arrows, the number at the top doesn’t change.

image

1 Like

When I said use the TeleportedStage value, I was talking about the script where you are teleporting character to stage when player respawn. As for the number, I updated the local script.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Stage = Player:WaitForChild("leaderstats"):WaitForChild("Stage")
local TeleportedStage = Player:WaitForChild("TeleportedStage")
local Remote = ReplicatedStorage:WaitForChild("StageTransfer")

num.Text = TeleportedStage.Value

num.FocusLost:Connect(function()
   if tonumber(num.Text) > Stage.Value then return end
   Remote:FireServer(tonumber(num.Text))
end)

right.MouseButton1Click:Connect(function()
   Remote:FireServer("right")
end)

left.MouseButton1Click:Connect(function()
   Remote:FireServer("left")
end)

num:GetPropertyChangedSignal("Text"):Connect(function()
   num.Text = num.Text:gsub("%D+", ""):sub(1, 3)
end)

TeleportedStage:GetPropertyChangedSignal("Value"):Connect(function()
   num.Text = TeleportedStage.Value
end)
2 Likes

That is the script I’m pretty sure. It activates when the player’s character loads. Also, thank you for the updated script.

Also, one more thing. When you join, it doesn’t show your stage. I tried adding something that fixes that, but it just didn’t let me click the arrows or change num.
image

1 Like

Try again with the new script, I edited it 5 seconds after I replied and added a line that should fix that.

1 Like

The second script in your reply is for checkpoints, probably.

1 Like

TeleportedStage:GetPropertyChangedSignal(“Value”):Connect(function()
num.Text = TeleportedStage.Value
end)

It doesn’t work for some reason assuming this is the line you meant.

1 Like

I meant this line at the beginning of the script.

num.Text = TeleportedStage.Value
1 Like

What do you mean? (characters)

1 Like

What this script does? I think its for checkpoints but it doesnt look very good.

1 Like

I adjusted all of the text to teleportedstage but it still teleports you to stage when you die.

1 Like

You should’ve not done that. Only replace Stage to TeleportedStage in the script where you teleport character to checkpoint on respawn.

1 Like

That’s what I did, though. (chars)

1 Like

Can you show me that script then? Also you said you replaced every Stage to TeleportedStage

1 Like
local checkpoints = workspace:WaitForChild("Checkpoints")

local coinremote = game.ReplicatedStorage:WaitForChild("CoinGet")

local ms = game:GetService("MarketplaceService")

local vip = 25751808
local mvp = 25751816
local dc = 25751830

game.Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	coins.Value = "0"
	coins.Parent = leaderstats
	
	local stage = Instance.new("IntValue")
	stage.Name = "Stage"
	stage.Value = "0"
	stage.Parent = leaderstats

	
	
	local prestige = Instance.new("IntValue")
	prestige.Name = "Prestige"
	prestige.Value = "0"
	prestige.Parent = leaderstats
	
	local effectvalue = Instance.new("NumberValue")
	effectvalue.Name = "efftime"
	effectvalue.Parent = player
	
	wait()
	
	local TeleportedStage = Instance.new("IntValue")
	TeleportedStage.Name = "TeleportedStage"
	TeleportedStage.Parent = player
	TeleportedStage.Value = stage.Value
	
	player.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")
		wait()
		char:MoveTo(checkpoints[stage.Value].Position)

		hum.Touched:Connect(function(hit)
			if hit.Parent == checkpoints then
				if tonumber(hit.Name) == player.TeleportedStage.Value + 1 then
					player.TeleportedStage.Value = player.TeleportedStage.Value + 1
					if not ms:UserOwnsGamePassAsync(player.UserId,vip) and not ms:UserOwnsGamePassAsync(player.UserId,mvp) and not ms:UserOwnsGamePassAsync(player.UserId,dc) then
						coins.Value = coins.Value + 5 -- none
					elseif ms:UserOwnsGamePassAsync(player.UserId,vip) and not ms:UserOwnsGamePassAsync(player.UserId,mvp) and not ms:UserOwnsGamePassAsync(player.UserId,dc) then
						coins.Value = coins.Value + 6 -- vip
					elseif not ms:UserOwnsGamePassAsync(player.UserId,vip) and not ms:UserOwnsGamePassAsync(player.UserId,mvp) and ms:UserOwnsGamePassAsync(player.UserId,dc) then
						coins.Value = coins.Value + 10 -- dc
					elseif not ms:UserOwnsGamePassAsync(player.UserId,vip) and ms:UserOwnsGamePassAsync(player.UserId,mvp) and not ms:UserOwnsGamePassAsync(player.UserId,dc) then
						coins.Value = coins.Value + 7 -- mvp
					elseif ms:UserOwnsGamePassAsync(player.UserId,vip) and ms:UserOwnsGamePassAsync(player.UserId,mvp) and not ms:UserOwnsGamePassAsync(player.UserId,dc) then
						coins.Value = coins.Value + 7 -- vip,mvp
					elseif ms:UserOwnsGamePassAsync(player.UserId,vip) and ms:UserOwnsGamePassAsync(player.UserId,mvp) and ms:UserOwnsGamePassAsync(player.UserId,dc) then
						coins.Value = coins.Value + 10 -- vip,mvp,dc
					elseif not ms:UserOwnsGamePassAsync(player.UserId,vip) and ms:UserOwnsGamePassAsync(player.UserId,mvp) and ms:UserOwnsGamePassAsync(player.UserId,dc) then
						coins.Value = coins.Value + 10 -- mvp,dc
					elseif ms:UserOwnsGamePassAsync(player.UserId,vip) and not ms:UserOwnsGamePassAsync(player.UserId,mvp) and ms:UserOwnsGamePassAsync(player.UserId,dc) then
						coins.Value = coins.Value + 10 -- vip,dc
					end
						
					coinremote:FireAllClients()
				end
			end
		end)
	end)	
end)



1 Like

Replace this with

char:MoveTo(checkpoints[TeleportedStage.Value].Position)

Thats the only thing you should have changed.
Also your script is just as awful as the first script. :slightly_smiling_face:

2 Likes