Raycast visual wont make particle for client

so what i want is that when the visual part gets fired particles appear, it works when i click run but when i click play it just shows the part and no particle

for the client its only the beam no particle.

here is the script :

wait(3)

local particle = script.Parent.Eye.Attachment.Charge1
local particle2 = script.Parent.Eye.Attachment.Charge2
local particle3 = script.Parent.Eye.Attachment.Charge3

local usedamount1 = 0
local usedamount2 = 0

local target 

for v,model in pairs(game.Workspace:GetChildren()) do
	if model:FindFirstChild("Humanoid") then
		target = model
	end
end



local function redirect(character)
	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {character} --ignore the character when raycasting
	raycastParams.FilterType = Enum.RaycastFilterType.Exclude

	--raycast towards whatever the player's mouse is aiming at 
	local startPos = character.Mirror.Position
	local range = 15051051050151051151 -- how far the raycast can travel 
	local aimDirection = (script.Parent.BallPart.Position - startPos).unit * range
	local rayResult = workspace:Raycast(startPos, aimDirection, raycastParams) -- raycast! 

	if rayResult then
		local hitPart = rayResult.Instance -- the part the raycast hit 
		local hitPos = rayResult.Position -- the position where the raycast hit 
		local distance = (hitPos - startPos).magnitude -- distance of our shot 

		
		print("pro")
		-- set up the laser part which just acts as a visual effect 
		local laserPart = Instance.new("Part")
		particle3.Enabled = false
		particle.Parent.Parent.Charge2:Stop()
		local clone = game.ServerStorage.LaserEffect4:Clone()
		local clone2 = game.ServerStorage.LaserSound4:Clone()
		clone2.Parent = laserPart
		clone2:Play()
		clone.Parent = laserPart
		clone:Emit(5 * distance)
		laserPart.Anchored = true 
		laserPart.Name = "Laser"
		laserPart.BrickColor = BrickColor.new("Really red")
		laserPart.Material = Enum.Material.Neon
		laserPart.CanCollide = false
		laserPart.Transparency = 0
		laserPart.Size = Vector3.new(0.2, 0.2, distance)
		laserPart.CFrame = CFrame.new(startPos, hitPos) * CFrame.new(0, 0, -distance / 2)
		laserPart.Parent = script.Parent
		script.Parent.BallPart.Explosion:Emit(50)
		script.Parent.BallPart.Smoke:Emit(150)
		script.Parent.BallPart.Sparks.Enabled = true
		script.Parent.Eye.Material = Enum.Material.Granite
		script.Parent.EyeBack.Material = Enum.Material.Granite
		script.Parent.BallPart.Material = Enum.Material.Granite
		script.Parent.CoolEye.Material = Enum.Material.Granite
		script.Parent.LookScript.Disabled = true
		script.Parent.ShootScript.Disabled = true
		wait(3)
		laserPart:Destroy()
	end
end

repeat
	local rnum = math.random(1,5)
	local bnum = math.random(1,5)
	if rnum ~= 1 and usedamount1 ~= 4 then

		particle.Enabled = true
		particle.Parent.Parent.Charge:Play()
		wait(1)
		usedamount1 += 1
		-- set up raycasting parameters   
		local raycastParams = RaycastParams.new()
		raycastParams.FilterDescendantsInstances = {script.Parent} --ignore the character when raycasting
		raycastParams.FilterType = Enum.RaycastFilterType.Exclude

		--raycast towards whatever the player's mouse is aiming at 
		local startPos = script.Parent.Eye.Position
		local range = 15051051050151051151 -- how far the raycast can travel 
		local aimDirection = (target.HumanoidRootPart.Position - startPos).unit * range
		local rayResult = workspace:Raycast(startPos, aimDirection, raycastParams) -- raycast! 

		if rayResult then
			local hitPart = rayResult.Instance -- the part the raycast hit 
			local hitPos = rayResult.Position -- the position where the raycast hit 
			local distance = (hitPos - startPos).magnitude -- distance of our shot 



			-- set up the laser part which just acts as a visual effect 
			local laserPart = Instance.new("Part")
			particle.Enabled = false
			particle.Parent.Parent.Charge:Stop()

			local clone = game.ServerStorage.LaserEffect2:Clone()
			local clone2 = game.ServerStorage.LaserSound:Clone()
			clone2.Parent = laserPart
			clone2:Play()
			clone.Parent = laserPart
			clone:Emit(5 * distance)
			laserPart.Anchored = true 
			laserPart.Name = "Laser"
			laserPart.BrickColor = BrickColor.new("Really red")
			laserPart.Material = Enum.Material.Neon
			laserPart.CanCollide = false
			laserPart.Transparency = 0
			laserPart.Size = Vector3.new(0.2, 0.2, distance)
			laserPart.CFrame = CFrame.new(startPos, hitPos) * CFrame.new(0, 0, -distance / 2)
			laserPart.Parent = script.Parent
			if hitPart then
				if hitPart.Parent:FindFirstChild("Humanoid") then
					local char = hitPart.Parent
					char.Humanoid:TakeDamage(5)
				end
			end
			wait(3)
			laserPart:Destroy()
		end
	elseif rnum == 1 or usedamount1 == 4 then
		usedamount1 = 0

		if bnum ~= 1 and usedamount2 ~= 4 then
			usedamount2 += 1
			particle.Enabled = true
			particle.Parent.Parent.Charge:Play()
			wait(1.5)
			particle2.Enabled = true
			wait(2.4)
			-- set up raycasting parameters   
			local raycastParams = RaycastParams.new()
			raycastParams.FilterDescendantsInstances = {script.Parent} --ignore the character when raycasting
			raycastParams.FilterType = Enum.RaycastFilterType.Exclude

			--raycast towards whatever the player's mouse is aiming at 
			local startPos = script.Parent.Eye.Position
			local range = 15051051050151051151 -- how far the raycast can travel 
			local aimDirection = (target.HumanoidRootPart.Position - startPos).unit * range
			local rayResult = workspace:Raycast(startPos, aimDirection, raycastParams) -- raycast! 

			if rayResult then
				local hitPart = rayResult.Instance -- the part the raycast hit 
				local hitPos = rayResult.Position -- the position where the raycast hit 
				local distance = (hitPos - startPos).magnitude -- distance of our shot 



				-- set up the laser part which just acts as a visual effect 
				local laserPart = Instance.new("Part")
				particle.Enabled = false
				particle2.Enabled = false

				particle.Parent.Parent.Charge:Stop()
				local clone = game.ServerStorage.LaserEffect3:Clone()
				local clone2 = game.ServerStorage.LaserSound2:Clone()
				clone2.Parent = laserPart
				clone2:Play()
				clone.Parent = laserPart
				clone:Emit(5 * distance)
				laserPart.Anchored = true 
				laserPart.Name = "Laser"
				laserPart.BrickColor = BrickColor.new("Really red")
				laserPart.Material = Enum.Material.Neon
				laserPart.CanCollide = false
				laserPart.Transparency = 0
				laserPart.Size = Vector3.new(0.2, 0.2, distance)
				laserPart.CFrame = CFrame.new(startPos, hitPos) * CFrame.new(0, 0, -distance / 2)
				laserPart.Parent = script.Parent
				if hitPart then
					if hitPart.Parent:FindFirstChild("Humanoid") then
						local char = hitPart.Parent
						char.Humanoid:TakeDamage(15)
					end
				end
				wait(3)
				laserPart:Destroy()
			end
		elseif bnum == 1 or usedamount2 == 4 then
			usedamount2 = 0
			particle.Enabled = true
			particle.Parent.Parent.Charge:Play()
			wait(1.5)
			particle2.Enabled = true
			wait(2.4)
			particle.Enabled = false
			particle2.Enabled = false
			particle3.Enabled = true
			particle2.Parent.Parent.Charge2:Play()
			wait(1.776)
			-- set up raycasting parameters   
			local raycastParams = RaycastParams.new()
			raycastParams.FilterDescendantsInstances = {script.Parent} --ignore the character when raycasting
			raycastParams.FilterType = Enum.RaycastFilterType.Exclude

			--raycast towards whatever the player's mouse is aiming at 
			local startPos = script.Parent.Eye.Position
			local range = 15051051050151051151 -- how far the raycast can travel 
			local aimDirection = (target.HumanoidRootPart.Position - startPos).unit * range
			local rayResult = workspace:Raycast(startPos, aimDirection, raycastParams) -- raycast! 

			if rayResult then
				local hitPart = rayResult.Instance -- the part the raycast hit 
				local hitPos = rayResult.Position -- the position where the raycast hit 
				local distance = (hitPos - startPos).magnitude -- distance of our shot 



				-- set up the laser part which just acts as a visual effect 
				local laserPart = Instance.new("Part")
				particle3.Enabled = false
				particle.Parent.Parent.Charge2:Stop()
				local clone = game.ServerStorage.LaserEffect4:Clone()
				local clone2 = game.ServerStorage.LaserSound3:Clone()
				clone2.Parent = laserPart
				clone2:Play()
				clone.Parent = laserPart
				clone:Emit(5 * distance)
				laserPart.Anchored = true 
				laserPart.Name = "Laser"
				laserPart.BrickColor = BrickColor.new("Really red")
				laserPart.Material = Enum.Material.Neon
				laserPart.CanCollide = false
				laserPart.Transparency = 0
				laserPart.Size = Vector3.new(0.2, 0.2, distance)
				laserPart.CFrame = CFrame.new(startPos, hitPos) * CFrame.new(0, 0, -distance / 2)
				laserPart.Parent = script.Parent
				if hitPart then
					if hitPart.Parent:FindFirstChild("Humanoid") then
						if hitPart.Parent:FindFirstChild("Mirror")then
							if hitPart.Parent:FindFirstChild("Mirror"):FindFirstChild("UseValue").Value == true then
								hitPart.Parent:FindFirstChild("Mirror").Attachment.ParticleEmitter:Emit(1)
								wait(0.5)
								laserPart:Destroy()
								redirect(hitPart.Parent)
							end

						else
							local char = hitPart.Parent
							char.Humanoid:TakeDamage(35)
						end

					end
				end
				wait(3)
				laserPart:Destroy()
			end
		end
	end
	task.wait(0.0000001)
until script.Disabled

help would be great :slightly_smiling_face:

1 Like