Hi i tried making a simple dash script, it works but i decided to add a trail effect when players are dashing.
it’s working but i noticed the trail wont appear to other players
(the script is in StarterCharacterScripts
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local debounce = false
local left_arm = character:WaitForChild("Left Arm") :: BasePart
local right_arm = character:WaitForChild("Right Arm") :: BasePart
local left_grip = left_arm.LeftGripAttachment
local left_shoulder = left_arm.LeftShoulderAttachment
local right_grip = right_arm.RightGripAttachment
local right_shoulder = right_arm.RightShoulderAttachment
local trail1 = Instance.new("Trail", script.Parent)
trail1.Name = "trail1"
local trail2 = Instance.new("Trail", script.Parent)
trail2.Name = "trail2"
uis.InputBegan:Connect(function(key, processed)
if debounce or processed then
return
end
if key.KeyCode == Enum.KeyCode.Q then
debounce = true
humanoid.WalkSpeed += 25
script.Sound.Playing = true
trail1.Parent = character
trail2.Parent = character
trail1.Parent = left_arm
trail2.Parent = right_arm
left_arm.trail1.Attachment0 = left_grip
left_arm.trail1.Attachment1 = left_shoulder
right_arm.trail2.Attachment0 = right_grip
right_arm.trail2.Attachment1 = right_shoulder
task.wait(0.5)
humanoid.WalkSpeed -= 25
left_arm.trail1.Attachment0 = nil
left_arm.trail1.Attachment1 = nil
right_arm.trail2.Attachment0 = nil
right_arm.trail2.Attachment1 = nil
end
task.wait(1.5)
debounce = false
end)
You need to do the trail applying to character inside server script because local script only shows to that player only, Use remote event.
2 Likes
You defined your trail in a LocalScript, meaning it will only show for the client.
Use a RemoteEvent to make it instead:
local createtrail = game:GetService("ReplicatedStorage").createtrail
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local debounce = false
local left_arm = character:WaitForChild("Left Arm") :: BasePart
local right_arm = character:WaitForChild("Right Arm") :: BasePart
local left_grip = left_arm.LeftGripAttachment
local left_shoulder = left_arm.LeftShoulderAttachment
local right_grip = right_arm.RightGripAttachment
local right_shoulder = right_arm.RightShoulderAttachment
createtrail:FireServer(script.Parent)
uis.InputBegan:Connect(function(key, processed)
if debounce or processed then
return
end
if key.KeyCode == Enum.KeyCode.Q then
debounce = true
humanoid.WalkSpeed += 25
script.Sound.Playing = true
trail1.Parent = character
trail2.Parent = character
trail1.Parent = left_arm
trail2.Parent = right_arm
left_arm.trail1.Attachment0 = left_grip
left_arm.trail1.Attachment1 = left_shoulder
right_arm.trail2.Attachment0 = right_grip
right_arm.trail2.Attachment1 = right_shoulder
task.wait(0.5)
humanoid.WalkSpeed -= 25
left_arm.trail1.Attachment0 = nil
left_arm.trail1.Attachment1 = nil
right_arm.trail2.Attachment0 = nil
right_arm.trail2.Attachment1 = nil
end
task.wait(1.5)
debounce = false
end)
Script in ServerScriptService:
local replicatedstorage = game:GetService("ReplicatedStorage")
replicatedstorage.createtrail.OnServerEvent:Connect(function(player, parent)
local trail1 = Instance.new("Trail", parent)
trail1.Name = "trail1"
local trail2 = Instance.new("Trail", parent)
trail2.Name = "trail2"
end)
2 Likes