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

Change Walkspeed if Gamepass Failure?

Asked by
Rynappel 212 Moderation Voter
4 years ago

So I have a script and when you touch a part, your walk speed it supposed change if you own a gamepass, it doesnt work and IDK why, I think the error is around the end, please help

local debounce = false 

function onTouch(part)

local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players.LocalPlayer, 7549271) then
human.WalkSpeed = 40
else
human.Walkspeed = 20
wait(1)
debounce = false
end 
end
end


script.Parent.Touched:connect(onTouch)
0
Indent your code please Leamir 3138 — 4y

1 answer

Log in to vote
2
Answered by
Leamir 3138 Moderation Voter Community Moderator
4 years ago

Hello, PurpleProgram!

You need to use player's Id when using marketPlaceService

Also, please corretly indent your code

local debounce = false 

function onTouch(part)

local human = part.Parent:findFirstChild("Humanoid")
    if (human ~= nil) and debounce == false then
    debounce = true
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, 7549271) then --Use UserId on marketplace service
            human.WalkSpeed = 40
        else
            human.Walkspeed = 20
            wait(1)
            debounce = false
        end 
    end
end


script.Parent.Touched:connect(onTouch)

If you need any more help, message me on roblox, post a comment or open a new question here on scripting helpers!

0
Ah yes, apologies for the un-indented code, thanks i will try this! Rynappel 212 — 4y
0
Still doesnt work Rynappel 212 — 4y
Ad

Answer this question