I'm having troubles making a coin that gives extra if you own a game pass such as a x2 coin pass. I have tried to edit this, by placing a if you own gamepass if, else thing here:
local id = 6488475 -- your gamepass id local db = true script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then if db == true then db = false script.Parent.Transparency = 1 local player = game.Players:GetPlayerFromCharacter(hit.Parent) local extra = 2 -- always add 1 extra to this such as if it gives +2 instead of 1, dont put 1, put 2. player.CharacterAdded:connect(function(char) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + extra -- etc
I did put a else afterwards and other stuff so. i just didn't put it up here. I'm trying to help my buddy out, and this would be useful to me to. ill put in the game pass id later of course. I have attempted to do this, i'm having troubles with the end not working. Here is the end part, i have done my best but a error still comes up:
end) end end)
I assume this is due to a incorrect if and else error or misplaced character or even a missing line that it needs. Please help me find the error, and fix it. Not trying to request.
local id = 6488475 -- your gamepass id local db = true script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then if db == true then db = false script.Parent.Transparency = 1 local player = game.Players:GetPlayerFromCharacter(hit.Parent) local extra = 2 -- always add 1 extra to this such as if it gives +2 instead of 1, dont put 1, put 2. player.CharacterAdded:connect(function(char) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + extra script.Sound:Play() wait(1) script.Parent.Transparency = 1 wait(10) -- time before respawn db = true script.Parent.Transparency = 0 else player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1 -- change 'Coins' to your currency name. script.Sound:Play() wait(1) script.Parent.Transparency = 1 wait(10) -- time before respawn db = true script.Parent.Transparency = 0 end end) end -- ending db or debounce end end)
Try this , i think the error was because you didn't end if db == true then
still dont work heres the full code
local id = 6488475 -- your gamepass id local db = true script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then if db == true then db = false script.Parent.Transparency = 1 local player = game.Players:GetPlayerFromCharacter(hit.Parent) local extra = 2 -- always add 1 extra to this such as if it gives +2 instead of 1, dont put 1, put 2. player.CharacterAdded:connect(function(char) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + extra script.Sound:Play() wait(1) script.Parent.Transparency = 1 wait(10) -- time before respawn db = true script.Parent.Transparency = 0 else player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1 -- change 'Coins' to your currency name. script.Sound:Play() wait(1) script.Parent.Transparency = 1 wait(10) -- time before respawn db = true script.Parent.Transparency = 0 end end) end end