How would i go about achieving the effect of a player, walking, and from the moment they go faster than a certain speed they get a special trail (trail on each attachment made in bodyparts, i also dont know how to make the attachments) and when they go slower the trail dissapears again.
(this is for a The Flash game of mine.)
My current effects involve just a trail on a part you hold while running which is pretty bad and is also just 1 block of trail, having a trail on each body part would be much better.
Check for changes in the players speed. If the speed is higher than the threshold, use a for loop to insert the trails,
else, delete the trails from the parts of the character
The local script would only fire once
And the part where you iterate through all of the parts of the character is rather inefficient. You should use a for loop and then check whether the instance in the character can have a trail attachment
Thats what he wants. I’m going to fix it because I have to make it when the character goes slower again.
Yes, a loop can do the trick, but you have to create separate attachments for each body part. I just said it was inefficient, if you have a better way then post it
What I mean is that the local script would only fire once, and it would fire only when the script has been added into the character by the game. That means it is not always checking the speed of the character, it only checks the speed once
I seem to have a problem where I don’t get the trail. I put WANTEDWALKSPEED as 60 and the top speed you can go is 500, I’m not sure if I have to put the WANTEDWALKSPEED exactly as the top speed or not, either way it didn’t work both ways. help?
On server: in a playeradded function, check when a players characters speed has changed. After that you can carry out the necessary checks. You can also do that on the client, although you will need to make use of a remote event
Sorry if it is against the guidelines, I can’t provide a script any further, but what you can do is if you already have a speed change script, you can check the players speed either in what @Amalgamous_prime told you or constantly check through a loop.
You can modify the code below to match your needs:
local Players = game:GetService("Players")
local trail = script.trail --trail path
local thereshold = 40
function Set(char, state)
for i, part in pairs(char:GetChildren()) do
if not part:IsA("BasePart") then continue end
local found = part:FindFirstChild(trail.Name)
if state and not found then
trail:Clone().Parent = part
elseif not state and found then
found:Destroy()
end
end
end
function PlayerAdded(player)
local function CharacterAdded(char)
local hum = char:WaitForChild("Humanoid", 5)
if not hum then return end
hum:GetPropertyChangedSignal("WalkSpeed"):Connect(function(speed)
if not tonumber(speed) then return end
if speed > thereshold then
Set(char, true)
else
Set(char, false)
end
end)
end
CharacterAdded(player.Character or player.CharacterAdded:Wait())
player.CharacterAdded:Connect(CharacterAdded)
end
for i, player in pairs(Players:GetPlayers()) do
PlayerAdded(player)
end
Players.PlayerAdded(PlayerAdded)