Players speed resets

this is a repost because it was flooded out by the problems Roblox had today.

In my game I wanted you to go faster when you touched the baseplate
Script (inside the baseplate):

local part = script.Parent
local num = .05
local CanFire = true

part.Touched:Connect(function(hit)
	if CanFire == true then
		if hit.Parent:FindFirstChild("Humanoid") then
			wait(.1)
			hit.Parent.Humanoid.WalkSpeed += num
			CanFire = false
			wait(.05)
			CanFire = true
			wait(.1)
		end
	end
end)

and I added a shop, where you can buy things that cost speed.
here is the script for that (it’s a local script inside starter character scripts):

-- player stuff--------------------
local plr = game.Players.LocalPlayer
local hum = plr.Character.Humanoid
-- player stuff--------------------


-----------GUI buttons---------------------------
local Item1 = game.ReplicatedStorage.ShopItem1GUI
local Item2 = game.ReplicatedStorage.ShopItem2GUI
-----------GUI buttons---------------------------


local ProxPrompt = game.Workspace.Bigtommyboi69.ProximityPrompt

wait(1)

ProxPrompt.Triggered:Connect(function(hit)
	
	------------ITEM 1-------------
	Item1.IgnoreGuiInset = false
	local Item1 = Item1:Clone()
	Item1.Parent = plr.PlayerGui
	Item1.ShopItem1GUIimage.MouseButton1Up:Connect(function(hit)
		Item1:Destroy()
	end)
	------------ITEM 1-------------
	
	------------ITEM 2-------------
	Item2.IgnoreGuiInset = false
	local Item2 = Item2:Clone()
	Item2.Parent = plr.PlayerGui
	Item2.ShopItem2GUIimage.MouseButton1Up:Connect(function(hit)
		 hum.WalkSpeed -= 10
	end)
	------------ITEM 2-------------
	
end)

so, after you buy something, you speed goes down by 10, but as soon as you take a step or jump, it goes back up to whatever you had before you bought that something.

1 Like

you have to remove the player speed from the server, use a remote event

3 Likes

Can you elaborate further please?
Sorry I’m not too great at scripting.

you are removing the player speed from the client (only seen by the player), you have to use a RemoteEvent to make the client communicate with the server and remove the speed. Also dont send the price in the RemoteEvent because exploiters can use it to get infinite speed, store the prices in server

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.