Why doesn't the part show on the server?

  1. What do you want to achieve? A fire trail sort of ability.

  2. What is the issue? I got the code how I want it but the fire effect only shows on the client, not the server even though I created the fire effect and parented it to the workspace in a server event.

  3. What solutions have you tried so far? none.

here’s the local script

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
local uis = game:GetService("UserInputService")
local run = false
local debounce = false

local rs = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Humanoid = workspace:WaitForChild(player.Name):WaitForChild("Humanoid")

--local AnimFire = script:WaitForChild("Animation")
--local AnimFirePlay = Humanoid:LoadAnimation(AnimFire)

local function isMoving() return Humanoid.MoveDirection.Magnitude > 0 end

local bg
local connection
uis.InputBegan:Connect(function(key, chat)
	if chat then return end
	if key.KeyCode == Enum.KeyCode.C and not debounce then
		debounce = true
		game.ReplicatedStorage.BloomRemotes.FireManipulation:FireServer("On", mouse.Hit)
		local AnimationTracks = Humanoid:GetPlayingAnimationTracks()
		for i, track in pairs (AnimationTracks) do
			track:Stop()
		end
		--AnimFirePlay:Play()
		bg = Instance.new("BodyGyro", char.HumanoidRootPart)
		bg.maxTorque = Vector3.new(500,500,500);
		bg.P = 10^7;
		bg.D = 100
		
		ReplicatedStorage.BloomRemotes.FireManipulation.OnClientEvent:Connect(function()
			connection = rs.RenderStepped:Connect(function()
				rs.RenderStepped:Wait()
				local direction = (player:GetMouse().Hit.p - char.HumanoidRootPart.Position) * Vector3.new(1,0,1)
				bg.CFrame = CFrame.new(char.HumanoidRootPart.Position, char.HumanoidRootPart.Position + direction)
				if workspace:FindFirstChild(player.Name.."'s Trail") then
					workspace:FindFirstChild(player.Name.."'s Trail").Position = mouse.Hit.p
				end
			end)
		end)
		
		wait(10)
		
		connection:Disconnect()
		game.Debris:AddItem(bg, .1)
		game.ReplicatedStorage.BloomRemotes.FireManipulation:FireServer("Off")
		
		--AnimFirePlay:Stop()
		wait(5)
		debounce = false		
	end
end)

here’s the server script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local Event = ReplicatedStorage.BloomRemotes.FireManipulation

local fire

Event.OnServerEvent:Connect(function(player, value, mouse)
	if value == "On" then
		fire = ReplicatedStorage.BloomPowers.FireTrail:Clone()
		fire.Name = player.Name.."'s Trail"
		fire.Parent = workspace
		
		player.Character.Humanoid.WalkSpeed = 0
		player.Character.Humanoid.JumpPower = 0
				
		if fire then 			
			Event:FireAllClients()
		end
	end
	
	if value == "Off" then
		fire:Destroy()
		player.Character.Humanoid.WalkSpeed = 16
		player.Character.Humanoid.JumpPower = 50
	end
end)

please note that i’m not that great of a scripter so all help would be appreciated : )

1 Like

its cuz ur making the part in client not on server. make part on server means it will be on server. make part in client means it will be on client.

4 Likes

also please try a few solutions instead of just making a whole topic
image

1 Like

The part is made in the server script

how about try parenting the trail to the player’s character like the player’s humanoidrootpart. Heres more information about trails: Trail | Roblox Creator Documentation

--LOCAL

local UserInput = game:GetService("UserInputService")
local Replicated = game:GetService("ReplicatedStorage")
local Run = game:GetService("RunService")
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart")
local Mouse = Player:GetMouse()

local Remotes = Replicated:WaitForChild("BloomRemotes")
local Fire = Remotes:WaitForChild("FireManipulation")

local Debounce = false
local Connection = nil

--local AnimFire = script:WaitForChild("Animation")
--local AnimFirePlay = Humanoid:LoadAnimation(AnimFire)

UserInput.InputBegan:Connect(function(Key, Processed)
	if Processed then
		return
	end
	
	if Debounce then
		return
	end
	
	if Key.KeyCode == Enum.KeyCode.C then
		Debounce = true
		
		Fire:FireServer("On", Mouse.Hit)
		--AnimFirePlay:Play()
		
		local BodyGyro = Instance.new("BodyGyro")
		BodyGyro.MaxTorque = Vector3.new(500, 500, 500)
		BodyGyro.P = 10^7
		BodyGyro.D = 100
		BodyGyro.Parent = HRP
		
		Fire.OnClientEvent:Connect(function()
			Connection = Run.RenderStepped:Connect(function()
				Run.RenderStepped:Wait()
				local Direction = Vector3.new(Mouse.Hit.Position.X - HRP.Position.X, 0, Mouse.Hit.Position.Z - HRP.Position.Z)
				BodyGyro.CFrame = CFrame.new(HRP.Position, HRP.Position + Direction)
				local Trail = workspace:FindFirstChild(Player.Name.."'s Trail")
				if Trail then
					Trail.Position = Mouse.Hit.Position
				end
			end)
		end)

		task.wait(10)

		Connection:Disconnect()
		BodyGyro:Destroy()
		Fire:FireServer("Off")
		--AnimFirePlay:Stop()
		
		task.wait(5)
		Debounce = false		
	end
end)
--SERVER
local Replicated = game:GetService("ReplicatedStorage")

local Remotes = Replicated.BloomRemotes
local Fire = Remotes.FireManipulation
local Powers = Replicated.BloomPowers
local FireTrail = Powers.FireTrail

Fire.OnServerEvent:Connect(function(Player, Value, Mouse)
	local Character = Player.Character
	local Humanoid = Character.Humanoid
	
	if Value == "On" then
		local Trail = FireTrail:Clone()
		Trail.Name = Player.Name.."'s Trail"
		Trail.Parent = workspace
		Trail:SetNetworkOwner(Player)

		Humanoid.WalkSpeed = 0
		Humanoid.JumpPower = 0
		Humanoid.JumpHeight = 0

		Fire:FireAllClients()
	end

	if Value == "Off" then
		local Trail = workspace:FindFirstChild(Player.Name.."'s Trail")
		if Trail then
			Trail:Destroy()
		end
		
		Humanoid.WalkSpeed = 16
		Humanoid.JumpPower = 50
		Humanoid.JumpHeight = 7.2
	end
end)

Might be worth adding print commands to ensure everything is executing as expected, the issue is likely replication related.

Perhaps you should give network ownership of the trail to the player it belongs to (as I have done above)? I’ve also added several other minor optimisations/fixes.

it looks like you’re cloning the trail itself and not the part?

1 Like