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

[URGENT] Doesnt 2x on touch if gamepass owned?

Asked by
Rynappel 212 Moderation Voter
5 years ago
Edited 5 years ago

So I have this script, and when you touch a part, its supposed to + 20 of the ingame currency Jump, if they have a gamepass, and if they do not have a gamepass, then it will + 10 of the ingame currency, but It doesnt work and I have no idea why, can somebody please help me. This is URGENT. Thank you merry christmas

01local debounce = true
02 
03script.Parent.Touched:Connect(function(partThatTouched)
04    local humanoid = partThatTouched.Parent:FindFirstChildWhichIsA("Humanoid") --Humanoid
05    if humanoid then
06        local player = game.Players:FindFirstChild(partThatTouched.Parent.Name) --Finds player
07        local PlrStatsJump = player.leaderstats:FindFirstChild("Jump")
08        if debounce then
09            debounce = false
10            if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(partThatTouched.UserId, 7549262) then
11            PlrStatsJump.Value = PlrStatsJump.Value + 20 -- Gamepass
12            wait (2)
13            debounce = true
14        else
15            PlrStatsJump.Value = PlrStatsJump.Value + 10 -- No Gamepass
View all 21 lines...

Also, the output says theres something wrong on line 10, (this is a script not a local script)

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

The issue is you have partThatTouched.UserId as the first Parameter in the market place service function, most likely, the part that touched is a body part. But you have the parts userId which is nil since parts don’t have user id’s. To make it work, you need a players user ID, so to do that, change PartThatTouched (on line 10) to

1game.Players:GetPlayerFromCharacter(hit.Parent).UserId
0
Thanks Rynappel 212 — 5y
Ad

Answer this question