Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

This script makes me crash!?!?

I have a normal script in workspace w/ this in it. It suppose to make me run 21 speed if I have a certain gamepass. It crashed my studio and it does not let me play in-game.

local passId = 278389550 -- change this to your game pass ID.
 
function isAuthenticated(player)
    return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end
 while true do
game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then
        plr.Character.Humanoid.WalkSpeed = 21
    end
end)
end

1 answer

✓ Accepted answer

An event doesn't need to be in an infinite loop to register all different connections. It automatically fires whenever it needs to.


local passId = 278389550 -- change this to your game pass ID.

function isAuthenticated(player)
    return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end

game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then
        plr.Character.Humanoid.WalkSpeed = 21
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.