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

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

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)

2 comments

0

That script is a ServerScript inside ServerScriptService, i have this script in StarterPlayerScripts:

0

l o o p i t

2 answers

✓ Accepted answer
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)

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)

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