Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Particle Emitter Trail Not Working On Server?

Asked by
hkmag 0
5 years ago
Edited 5 years ago

This is going to be long, but I have been pulling my hair out for weeks over this. I have a particle emitter trail that follows the player, and it works on the client side, but when I try to put it on the server for everyone to see, it gets deleted after 3 seconds and the server and other players never see it to begin with.

The model consists of a primary part which gets CFramed to the player, and has 9 child parts which have particle emitters and are individually welded to the primary part, and a localscript that CFrames the primary part to the player.

This is the localscript:

local bp = script.Parent.Parent
local plr = game.Players.LocalPlayer.Name
local Character = game.Workspace[plr]
for i,v in pairs(bp:GetChildren()) do
    v.CFrame = (Character.UpperTorso.CFrame)
end
while wait() do
for i,v in pairs(bp:GetChildren()) do
    if v:IsA("BasePart") then
        local w = Instance.new("Weld", v)
        w.C0 = (v.CFrame:inverse() * Character.UpperTorso.CFrame)

        w.Part0 = v
        w.Part1 = Character.UpperTorso
        v.Anchored = false
        v.CanCollide = false
    end
end
end

I have searched endlessly on how to properly insert models from server to client, and some people say to store the trail in server storage, and others say to store it in replicated storage. I chose to put the trail in replicated storage, and use a RemoteEvent in replicated storage and a script in server script storage. This is the script in server script storage:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local trailEvent = Instance.new("RemoteEvent", ReplicatedStorage)
trailEvent.Name = "TrailEvent"

local function onTrailFired(plr)
    game.ReplicatedStorage.RedTrail:Clone().Parent = game.Workspace:WaitForChild(plr)
end

trailEvent.OnServerEvent:Connect(onTrailFired())

This is fired from a screen gui in startergui, through this localscript:

local char = game.Players.LocalPlayer.Name

button = script.Parent
button.MouseButton1Down:connect(function()
    game.ReplicatedStorage.TrailEvent:FireServer(char)
end)

Any help with this would be great, because I am at a completely standstill until I can get this problem resolved.

0
put your trail in serverstorage, send signal to server via client and do the stuff on the server. this is the secure route. SaltyPotter 362 — 5y
0
For some reason it just gets deleted though when I do that. lasts for 3 seconds then vanishes hkmag 0 — 5y
0
In the serverscript you need to weld the redtrail and call onTrailFired without (). Also to find the character just do plr.Character instead of game.Workspace[plr]. Rheines 661 — 5y
0
Rheines Thanks! It finally works properly and I am so happy! I would mark that as the answer if it wasnt a comment hkmag 0 — 5y

Answer this question