I can’t seem to make a script that makes particle emitter(s) and Point lights go from being parented to ServerStorage, to then be parented to a player when they have a certain tool in their BACKPACK. I also need the effects and lights to be visible to everyone as well. help is appreciated
The only thing I can really provide is the LocalScript located in StarterCharacterScripts:
local ElectricityLight = game.ServerStorage.ElectricityLight
local ElectricityParticles = game.ServerStorage.Electricity
local HitCube = script.Parent:FindFirstChild("HitCube") --HitCube is a part inside the player that all the effets are being moved to.
local Player = game:GetService("Players").LocalPlayer
if Player.Backpack:WaitForChild("Electricity") then
ElectricityLight.Parent = HitCube
ElectricityParticles.Parent = HitCube
ElectricityLight.Enabled = true
ElectricityParticles.Enabled = true
else
ElectricityLight.Parent = game.ServerStorage
ElectricityParticles.Parent = game.ServerStorage
ElectricityLight.Enabled = false
ElectricityParticles.Enabled = false
end
You’re only checking for the tool once. Use Child Added and Child Removed to check every time something gets added:
local ElectricityLight = game.ServerStorage.ElectricityLight
local ElectricityParticles = game.ServerStorage.Electricity
local HitCube = script.Parent:FindFirstChild("HitCube") --HitCube is a part inside the player that all the effets are being moved to.
local Player = game:GetService("Players").LocalPlayer
function checkForTool()
if Player.Backpack:WaitForChild("Electricity") then
ElectricityLight.Parent = HitCube
ElectricityParticles.Parent = HitCube
ElectricityLight.Enabled = true
ElectricityParticles.Enabled = true
else
ElectricityLight.Parent = game.ServerStorage
ElectricityParticles.Parent = game.ServerStorage
ElectricityLight.Enabled = false
ElectricityParticles.Enabled = false
end
end
Player.Backpack.ChildAdded:Connect(checkForTool)
Player.Backpack.ChildRemoved:Connect(checkForTool)
I tried and this DOES enable the effects but for some reason other players cant see the effects on my body. Idk what causing this to happen. Also I need this to still be working after I die. Please help! thank you! Also Idk if this important but I have a custom starter character for the players that the HitCube is in.
How would the server script version of it look like? All I did was copy and paste the same script but as a server script and made Local Player = game:GetService("Players").LocalPlayer into Local Player = game:GetService("Players") Help would be appreciated