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

How to convert this broken running script into normal script?

speed = 25 --16 is default
local marketplaceService = game:GetService("MarketplaceService")
local gamepassId = 0 -- your gamepass ID here
local speed = 25 -- set to whatever walking speed you want

game.Players.PlayerAdded:Connect(function(player)
    repeat wait() until player.Character
    if (marketplaceService:PlayerOwnsAsset(player, gamepassId) then
        speed = 50
        return
    end
end)

function onPlayerRespawned(character)
	wait(1) --loading delay
	local player = game.Players:GetPlayerFromCharacter(character)
	local human = character:findFirstChild("Humanoid")
	if player ~= nil and human ~= nil then
		human.WalkSpeed = speed
	end
end

game.Workspace.ChildAdded:connect(onPlayerRespawned)

1 answer

✓ Accepted answer

Try

local defaultspeed = 25 --16 is default
local Market = game:GetService("MarketplaceService")
local gamepassId = 0 -- your gamepass ID here
local gamepassspeed = 50 -- set to whatever walking speed you want

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        if Market:UserOwnsGamePassAsync(plr.UserId,gamepassId) then
            char.Humanoid.WalkSpeed = tonumber(defaultspeed)
        else
            char.Humanoid.WalkSpeed = tonumber(gamepassspeed)
        end
    end
end)


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