Also set the name of second table to gamepassToCoins so there will be no variables with the same names.
So I tried replacing the text, nothing worked, and then added the text, which at least got the leaderstats working but didn’t work when i tried to get the checkpoint.
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 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
local gamepassToCoins = {["VIP"] = 25751808, ["MVP"] = 25751816, ["DC"] = 25751830}
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
wait()
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
wait()
char:MoveTo(checkpoints[TeleportedStage.Value].Position)
hum.Touched:Connect(function(hit)
local gamepasses = {
["VIP"] = 5, --How many coins to give?
["MVP"] = 7,
["DC"] = 10,
}
for k, v in pairs(gamepasses) do --This will iterate through table. k - gamepass name, v - how many coins it gives
if player[k].Value then --Means player has gamepass
coins.Value += v
end
end
if hit.Parent == checkpoints then
for name, ID in pairs(gamepasses) do
local success, ownsPass = pcall(ms.UserOwnsGamePassAsync, ms, player.UserId, ID)
if success and ownsPass then
player[name].Value = true
end
end
--[[
if tonumber(hit.Name) == player.leaderstats.Stage.Value + 1 then
player.leaderstats.Stage.Value = player.leaderstats.Stage.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)
No, no, no.
I’ll better do it for you.
local checkpoints = workspace:WaitForChild("Checkpoints")
local coinremote = game.ReplicatedStorage:WaitForChild("CoinGet")
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamepassToCoins = {
["VIP"] = 5,
["MVP"] = 7,
["DC"] = 10,
}
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")
char:MoveTo(checkpoints[TeleportedStage.Value].Position)
hum.Touched:Connect(function(hit)
if hit.Parent == checkpoints and tonumber(hit.Name) == stage.Value + 1 then
for k, v in pairs(gamepassToCoins) do
if player[k].Value then
coins.Value += v
end
end
stage.Value = hit.Name
end
end)
end)
end)
This doesnt include stage updating.
Edit: now it does
One, when I join, my stage value is 0 but the top says my actual stage.
Two, when I touch a checkpoint, I get a random amount of coins. I get a lot of coins.
Also, when I respawn, I respawn at stage 0.
What is the top?
Its not actually random. You can set how many coins each gamepass gives. If I understand correctly, you want to give player coints for each checkpoint they touch?
Did you mean leaderboard by the top?
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.
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…
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
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!!!