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
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)