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

Change Walkspeed If Gamepass End Not Working?

Asked by
Rynappel 212 Moderation Voter
4 years ago

Im not good with outputs, this is the output: 10:14:12.531 - Workspace.Part.WalkSpeed:32: Expected 'end' (to close 'then' at line 6), got <eof>

and this is the code:

local debounce = false 

function onTouch(part)

local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true

local id = 7549271

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then
        plr.Character.Humanoid.WalkSpeed = 40
    end
end)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
            char.Humanoid.WalkSpeed = 40
human.WalkSpeed = 40
else
human.Walkspeed = 20
wait(1)
debounce = false


script.Parent.Touched:connect(onTouch)

        end
    end)
end)

1 answer

Log in to vote
1
Answered by 4 years ago
local id = 7549271

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then
        if plr.Character then
            plr.Character:WaitForChild("Humanoid").WalkSpeed = 40
        end
    end
end)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then
            char.Humanoid.WalkSpeed = 40
        else
            char.Humanoid.WalkSpeed = 20
        end
    end)
end)

If you put this in a script in ServerScriptService, it will work.

0
Yeh thanks but I wanted it only to work if they touch a part, can you do that for me? Rynappel 212 — 4y
Ad

Answer this question