Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm confused, when I try to make a x2 coin pass it complains about the end, but I don't know why?

Asked by 5 years ago

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:

01local id = 6488475 -- your gamepass id
02 
03local db = true
04script.Parent.Touched:connect(function(hit)
05    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
06        if db == true then
07            db = false
08            script.Parent.Transparency = 1
09            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
10            local extra = 2 -- always add 1 extra to this such as if it gives +2 instead of 1, dont put 1, put 2.
11            player.CharacterAdded:connect(function(char)
12            if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
13            player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + extra
14-- 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:

1end)
2 
3        end
4 
5end)

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.

2 answers

Log in to vote
0
Answered by 5 years ago
01local id = 6488475 -- your gamepass id
02 
03local db = true
04script.Parent.Touched:connect(function(hit)
05    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
06        if db == true then
07            db = false
08            script.Parent.Transparency = 1
09            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
10            local extra = 2 -- always add 1 extra to this such as if it gives +2 instead of 1, dont put 1, put 2.
11            player.CharacterAdded:connect(function(char)
12            if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
13            player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + extra
14            script.Sound:Play()
15            wait(1)
View all 32 lines...

Try this , i think the error was because you didn't end if db == true then

0
If it doesn't work tell me, also if it drops an error i may need it maumaumaumaumaumua 628 — 5y
0
It does not work, after editing it, it seems to dropa error related to the if game:GetService etc, so it seems to be messed up there, if u can fix it tell me, otherwise ill try my best RobloxGameingStudios 145 — 5y
0
Thanks a bit. I got this to work by changing some lines and connecting it to a true or false value if user owns game pass. but the end and debounce thing helped! RobloxGameingStudios 145 — 5y
0
I'm very happy to hear that! maumaumaumaumaumua 628 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

still dont work heres the full code

01local id = 6488475 -- your gamepass id
02 
03local db = true
04script.Parent.Touched:connect(function(hit)
05    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
06        if db == true then
07            db = false
08            script.Parent.Transparency = 1
09            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
10            local extra = 2 -- always add 1 extra to this such as if it gives +2 instead of 1, dont put 1, put 2.
11            player.CharacterAdded:connect(function(char)
12            if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
13            player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + extra
14            script.Sound:Play()
15            wait(1)
View all 31 lines...

Answer this question