Difficulty Chart Obby: How can I reduce this script?

The top is the stage transfer. I want the coins to work like they worked before; coins were given depending on which gamepasses you owned.

Coins were given once every time you touched a new checkpoint that you’ve not touched befrore.

It actually works like this right now. I edited the script to only give coins if you touched checkpoint for the first time.

1 Like

It gives all three adding up to 22

7+5+10

I own all 3 gamepasses which is the problem. The old script made it so that I would only get 10.

I though that its what you need. So you want to give amount of coins based on the best gamepass?

If you have just VIP, you get 5 coins. If you for some reason have VIP and MVP, you only get 7, not 12. If you have just MVP, you also only get 7. If you have VIP, MVP, and Double Coins, you get 10 coins regardless of the fact you have VIP and MVP.

So it doesnt matter how many gamepasses you have? The amount is based on the best gamepass? VIP → MVP → DC?

Yes. (characters aaaaaaaaaaa) aaa

local checkpoints = workspace:WaitForChild("Checkpoints")

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

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamepasses = {["VIP"] = 25751808, ["MVP"] = 25751816, ["DC"] = 25751830}

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 VIP = Instance.new("BoolValue")
	VIP.Name = "VIP"
	VIP.Parent = player

	local MVP = Instance.new("BoolValue")
	MVP.Name = "MVP"
	MVP.Parent = player

	local DC = Instance.new("BoolValue")
	DC.Name = "DC"
	DC.Parent = player

    for name, ID in pairs(gamepasses) do
		local success, ownsPass = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, player.UserId, ID)
		if success and ownsPass then
			player[name].Value = true
		end
	end
	
	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
	
	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")
        task.wait()
		char:MoveTo(checkpoints[TeleportedStage.Value].Position)

		hum.Touched:Connect(function(hit)
			if hit.Parent == checkpoints and tonumber(hit.Name) == stage.Value + 1 then
            local Coins = 0
		    if VIP.Value then
		       Coins = 5
	        end
            if MVP.Value then
		       Coins = 7
	        end
            if DC.Value then
		       Coins = 10
	        end
            coins.Value += Coins
            stage.Value = hit.Name
            TeleportedStage.Value = hit.Name
            end
		end)
	end)	
end)

Big script formatting is a big problem on the DevForum…

2 Likes

Lol. So the coin part works, but we’re having the same issue as before. I spawned at stage 0 and the stage transfer thing at the top doesn’t update when i advance stages.

Copy the new script and try again :slightly_smiling_face:

It works like a charm. I’d like to just say thanks for bearing with me here, this was a long and frustrating process but the result is great. Thank you so much!!!

2 Likes