my script is: i added it to a part which i thought it would only work while you are in a part but it didnt work
game.Players.PlayerAdded:Connect(function(plr) local loaded = plr:HasAppearanceLoaded() while not loaded do wait() loaded = plr:HasAppearanceLoaded() end
local StartingSpeed = 5 local Speed = StartingSpeed local SpeedMultiplier = 1.002 local Delay = 3 local human = plr.Character:FindFirstChild("Humanoid") local debounce = false human.Running:Connect(function(plr) while human:GetState() == Enum.HumanoidStateType.Running do wait() if human.MoveDirection.magnitude > 0 then if debounce == false then debounce = true Speed = Speed * SpeedMultiplier human.WalkSpeed = Speed wait(Delay) debounce = false end end end end) plr.CharacterAdded:Connect(function(char) local humanoid = char:FindFirstChild("Humanoid") humanoid.WalkSpeed = Speed humanoid.Running:Connect(function(plr) while humanoid:GetState() == Enum.HumanoidStateType.Running do wait() if humanoid.MoveDirection.magnitude > 0 then if debounce == false then debounce = true Speed = Speed * SpeedMultiplier humanoid.WalkSpeed = Speed wait(Delay) debounce = false end end end end) end)
end)
Do you mean like you're faster inside a part and return to normal speed when leaving it?
If yes, then this will be the script. I recommend using my module that detects when a part or a model is inside a specific part. You can require it using require(10601121934)
or getting it from the website.
-- Normal Script in ServerScriptService local Players = game:GetService("Players") local RegionPartService = require(10601121934) local SpeedZone = workspace.SpeedZone -- for this example we have a part called "SpeedZone" Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) local Humanoid = Character:WaitForChild("Humanoid") while true do local isCharacterInRegion = RegionPartService:IsPartInRegion(SpeedZone, Character) if isCharacterInRegion == true then Humanoid.WalkSpeed = 16*2 -- doubles the player speed else Humanoid.WalkSpeed = 16 -- returns to normal speed end task.wait() end end) end)
but if you want to make your speed faster after touching the part once, you can simple use the BasePart.Touched
event.
-- Normal Script inside "SpeedZone" local Players = game:GetService("Players") local SpeedZone = script.Parent SpeedZone.Touched:Connect(function(otherPart) local otherCharacter = otherPart.Parent local otherHumanoid = otherCharacter:FindFirstChildWhichIsA("Humanoid") local otherPlayer = Players:GetPlayerFromCharacter(otherCharacter) if otherCharacter and otherHumanoid and otherPlayer then otherHumanoid.WalkSpeed = 16*2 -- doubles the player speed end end)