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

How would I make it so the walkspeed doesnt reset on death?

Asked by
Ben_B 9
4 years ago
game.Players.PlayerAdded:Connect(function(player)
wait(1)
local hasPass = false 
local success, message = pcall(function()
    hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId,           gamePassID)
end)
if hasPass == true or player.UserId == 94204218 then

    player.Character.Humanoid.WalkSpeed = 30
end

end)

0
That script is a ServerScript inside ServerScriptService, i have this script in StarterPlayerScripts: Ben_B 9 — 4y
0
l o o p i t greatneil80 2647 — 4y

2 answers

Log in to vote
2
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local GamepassId = --// Id
local GamepassWalkspeed = 30

local GiveToIds = {
    [94204218] = true
}

local function SetWalkSpeed(Player)
    local HasPass = MarketplaceService:UserOwnsAssetAsync(Player.UserId, GamepassId)
    if (HasPass or GiveToIds[Player.UserId] then
        Player.CharacterAdded:Connect(function(Character)
            local Humanoid = Character:FindFirstChildOfClass("Humanoid")
            if (Humanoid) then
                Humanoid.WalkSpeed = GamepassWalkSpeed
            end
        end)
    end
end

Players.PlayerAdded:Connect(SetWalkSpeed)
Ad
Log in to vote
1
Answered by 4 years ago

Make a nested function that triggers every time the player's character respawns.

Try this:

game.Players.PlayerAdded:Connect(function(player)

    local AssetID = 123456789 -- Insert your AssetID here

    player.CharacterAdded:Connect(function(player)

        if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, AssetID) or player.UserId == 94204218 then

            player.Character.Humanoid.WalkSpeed = 30

        end
    end)    

end)

Answer this question