AHHHH IT WORKS!!! TYSM for helping me out with this issue! sorry i was kinda slow when it came to the scripting part but yayyy
How to make particle enabled and visible to everyone if player has a certain tool in their BACKPACK?
broooo it should me that whos sorry broo it took 3hours for me to help u
ohh that doesnt matter! You were my solution and thats all that matters! tysm
wait sorry there’s one more thing! every time I physically equip and unequip the tool. it clones the particles making a ton of them! how can I fix this?
you add a Light1:destroy(),Light2:Destroy() after the enabled = false
or you could add a debris for it instead of destroy()
add a debris like 0.5 after the parent = nil
Debris:AddItem(Light1,0.5)
Debris:AddItem(Light2,0.5)
Still having the same issue. Here’s my entire script if u need it: (I deleted the Debris part of the script bc it wasn’t working)
local HitCube = script.Parent:FindFirstChild("HitCube") --HitCube is a part inside the custom startercharacter that contains all the effects/lights.
local Player = game:GetService("Players").LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local character = Player.Character
local Debris = game:GetService("Debris")
local RemoteEvent = ReplicatedStorage.LightEvent -- so the client script could see the remote event
local backpack = Player.Backpack
RemoteEvent.OnClientEvent:Connect(function(data)
local Light1 = HitCube:FindFirstChild("Light1"):Clone()
local Light2 = HitCube:FindFirstChild("Light2"):Clone()
if data.ActionType == "Light" then
Light1.Parent = data.Parent
Light2.Parent = data.Parent
Light1.Enabled = true
Light2.Enabled = true
elseif data.ActionType == "LightCanceled" then
Light1.Enabled = false
Light2.Enabled = false
Light1.Parent = nil
Light2.Parent = nil
end
end)
local function Check_For_Tool()
if backpack:FindFirstChild("Light") or character:FindFirstChild("Light") then
RemoteEvent:FireServer("Light")
else
RemoteEvent:FireServer("LightCanceled")
end
end
Player.Backpack.ChildAdded:Connect(Check_For_Tool)
Player.Backpack.ChildRemoved:Connect(Check_For_Tool)
add a debris for it to destroy itself
You should check if the particle exists before cloning them.
I tried but all it’s doing is just duplicating Light1 and Light2 every time I equip/unequip the tool:
and it also looks like some of them are enabled and some of them aren’t…
local HitCube = script.Parent:FindFirstChild(“HitCube”) --HitCube is a part inside the custom startercharacter that contains all the effects/lights.
local Player = game:GetService(“Players”).LocalPlayer
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local character = Player.Character
local Debris = game:GetService(“Debris”)
local RemoteEvent = ReplicatedStorage.LightEvent – so the client script could see the remote event
local backpack = Player.Backpack
RemoteEvent.OnClientEvent:Connect(function(data)
if data.ActionType == "Light" then
local Light1 = HitCube:FindFirstChild("Light1"):Clone()
local Light2 = HitCube:FindFirstChild("Light2"):Clone()
Light1.Parent = data.Parent
Light2.Parent = data.Parent
Light1.Enabled = true
Light2.Enabled = true
elseif data.ActionType == "LightCanceled" then
Light1.Enabled = false
Light2.Enabled = false
Light1.Parent = nil
Light2.Parent = nil
Light1:Destroy()
Light2:Destroy()
end
end)
local function Check_For_Tool()
if backpack:FindFirstChild(“Light”) or character:FindFirstChild(“Light”) then
RemoteEvent:FireServer(“Light”)
else
RemoteEvent:FireServer("LightCanceled")
end
end
Player.Backpack.ChildAdded:Connect(Check_For_Tool)
Player.Backpack.ChildRemoved:Connect(Check_For_Tool)
this should fully work now because now everytime the remoteEvent fires back it wont clone until the actiontype == “Light”
RemoteEvent.OnClientEvent:Connect(function(data)
if data.ActionType == "Light" then
local Light1 = HitCube:FindFirstChild("Light1") :Clone()
local Light2 = HitCube:FindFirstChild("Light2"):Clone()
Light1.Name = "Light1"
Light2.Name = "Light2"
Light1.Parent = data.Parent
Light2.Parent = data.Parent
Light1.Enabled = true
Light2.Enabled = true
elseif data.ActionType == "LightCanceled" then
for _,v in pairs(data.Parent:GetChildren()) do
if v.Name == "Light1" or "Light2" then
v:Destroy()
end
end
end
end)
ughh idk why but it’s still duplicating it.
im not the one to give up but I’m getting second thoughts about this.
try restarting ur roblox studio because it should destroy the particleEmitter if the name matches
try prints() to see if the destroy() passes
nope. restarting studio didn’t work.