The scripts below add a trail in attachments when the player exceeds a certain speed, though the problem is the trail doesnt dissapear when the player goes below the certain speed.
For the script to work:
RemoveEvent and a value named Speed in Replicated storage
script 1: goes in ServerScriptService in a normal script
local remoteevent = game.ReplicatedStorage.RemoteEvent
local trail = game.ServerStorage.Trail
remoteevent.OnServerEvent:Connect(function(player)
local character = player.Character
-- Trail 1
local trail1 = trail:Clone()
trail1.Parent = character
local attachment0 = Instance.new("Attachment", character.Head)
attachment0.Name = "TrailAttachment0"
local attachment1 = Instance.new("Attachment", character.HumanoidRootPart)
attachment1.Name = "TrailAttachment1"
trail1.Attachment0 = attachment0
trail1.Attachment1 = attachment1
-- Trail 2
local trail2 = trail:Clone()
trail2.Parent = character
local attachment2 = Instance.new("Attachment", character.RightUpperArm)
attachment2.Name = "TrailAttachment2"
local attachment3 = Instance.new("Attachment", character.RightHand)
attachment3.Name = "TrailAttachment3"
trail2.Attachment0 = attachment2
trail2.Attachment1 = attachment3
-- Trail 3
local trail3 = trail:Clone()
trail3.Parent = character
local attachment4 = Instance.new("Attachment", character.LeftUpperArm)
attachment2.Name = "TrailAttachment4"
local attachment5 = Instance.new("Attachment", character.LeftHand)
attachment3.Name = "TrailAttachment5"
trail3.Attachment0 = attachment4
trail3.Attachment1 = attachment5
-- Trail 4
local trail4 = trail:Clone()
trail4.Parent = character
local attachment6 = Instance.new("Attachment", character.LeftUpperLeg)
attachment6.Name = "TrailAttachment4"
local attachment7 = Instance.new("Attachment", character.LeftFoot)
attachment7.Name = "TrailAttachment5"
trail4.Attachment0 = attachment6
trail4.Attachment1 = attachment7
-- Trail 5
local trail5 = trail:Clone()
trail5.Parent = character
local attachment8 = Instance.new("Attachment", character.RightUpperLeg)
attachment6.Name = "TrailAttachment4"
local attachment9 = Instance.new("Attachment", character.RightFoot)
attachment7.Name = "TrailAttachment5"
trail5.Attachment0 = attachment8
trail5.Attachment1 = attachment9
end)
Script 2: Localscript inside StarterCharacterScripts
local player = game.Players.LocalPlayer
local character = player.Character or script.Parent
local humanoid = character.Humanoid
local remoteevent = game.ReplicatedStorage.RemoteEvent
while humanoid.WalkSpeed == 16 do
print(humanoid.WalkSpeed)
for i,v in pairs(character:GetChildren()) do
if v:IsA("Trail") then
v:Destroy()
end
end
wait()
end
remoteevent:FireServer()
Script 3 : localscript in StarterCharacterScripts
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char.Humanoid
local UserInputService = game:GetService("UserInputService")
local speed = game.ReplicatedStorage.Speed.Value
UserInputService.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.LeftShift then
speed = true
while speed == true do
if hum.WalkSpeed == 250 then break end
hum.WalkSpeed = hum.WalkSpeed + 1
wait()
end
end
end)
UserInputService.InputEnded:Connect(function(input, isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.LeftShift then
speed = false
repeat
if speed == true then break end
hum.WalkSpeed = hum.WalkSpeed - 1
wait()
until
hum.WalkSpeed == 16
end
end)
Script 4: Localscript in StarterCharacterScripts
local player = game.Players.LocalPlayer
local character = player.Character or script.Parent
local humanoid = character.Humanoid
local remoteevent = game.ReplicatedStorage.RemoteEvent
if humanoid.WalkSpeed == 60 then
remoteevent:FireServer()
end
.