Help with scripting

idk how to name this post

the first player can see other player trail even when i didnt activate it yet
im very bad at scripting tho

--extracted script
repeat wait() until game.Players.LocalPlayer.Character
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local PressedMouseButton = ""
local Equipped = false
local Combo = 0
local Debounce = false
local SoulsInputDelayTime = 0.1
local Trail = script.Parent["Arming Sword"].Trail
Trail.Enabled = false
local Tip = script.Parent["Arming Sword"].Tip 
Tip.Enabled = false

local Idle = humanoid:LoadAnimation(script.Parent.Animation.Idle)
local Open = humanoid:LoadAnimation(script.Parent.Animation.Open)
local Close = humanoid:LoadAnimation(script.Parent.Animation.Close)
local L1 = humanoid:LoadAnimation(script.Parent.Animation.L1)
UserInputService.InputBegan:Connect(function(input, gpe)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then -- Left mouse button
		PressedMouseButton = "LEFT"
		script.Parent:Activate()
	elseif input.UserInputType == Enum.UserInputType.MouseButton2 then -- Right mouse button
		PressedMouseButton = "RIGHT"
		script.Parent:Activate()
	end
end)
local function ActivateTrail(Length, DelayTime)
	wait(DelayTime)
	Trail.Enabled = true
	Tip.Enabled = true
	wait(Length)
	Trail.Enabled = false
	Tip.Enabled = false
end

script.Parent.Equipped:Connect(function()
	Open:Play()
	Open.Stopped:wait()
	Equipped = true
	Idle:Play()
end)
script.Parent.Activated:Connect(function()
	if PressedMouseButton == "LEFT" then
		if Combo == 0 and Debounce == false then
			wait(SoulsInputDelayTime)
			humanoid.AutoRotate = false
			humanoid.WalkSpeed = 0
			Debounce = true
			L1:Play()
			spawn(function()ActivateTrail(0.35, 0.15)end)
			Combo = Combo + 1		
			L1.Stopped:Wait()
			humanoid.AutoRotate = true
			humanoid.WalkSpeed = 16
			Debounce = false
		end
	elseif PressedMouseButton == "RIGHT" then
		print("rightmouse didnt do anything (Yet)")
	end
end)


script.Parent.Unequipped:Connect(function()
	Equipped = false
	Idle:Stop()
	Close:Play()
	Close.Stopped:wait()
end)
2 Likes

If you enable/disable the trail on the client, only that client will have the change applied.

Use a remote event and have the server set the enabled property for it to replicate to everyone.

2 Likes

How can i do so

i have absolutely no idea

1 Like

I suggest looking up a remote event introduction tutorial on youtube, can be really helpful for changing values from the value and updating it on the server.

1 Like

Instead should have the client first enable the trail, send a remote to the server that then sends a remote to every other client except them to enable the trail on their client. Most if not all visuals should be done on the client

1 Like

How can i achieve so

ive been tinkering around the script and still cant figure out how remote event work :skull: