How to make particle emitters work in local script, and only visible for the player

I’ve got a viewmodel in replicated storage that is activated by a local script, the viewmodel has a particleEmitter, everything in it works except the particle emitter won’t emit for the player, I don’t understand what the problem is?

Any ideas?

maybe show the script atleast for once

particles don’t work in viewmodels for whatever reason

1 Like

fine, I wasn’t showing the script because its a lil bit big but ok.

local RunService = game:GetService("RunService")
local tool = script.Parent.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local FireFire = script.Parent.Parent.FireFire
local ToolEquipped = false
local UIS = game:GetService('UserInputService')
local mouse = game.Players.LocalPlayer:GetMouse()

tool.Spell.Fire.LocalTransparencyModifier = 1
tool.Spell["Sphere.001"].LocalTransparencyModifier = 1

--128668022042414 Avatar Spell Cast
--74624677164025 ViewModel Spell Cast
--118011158081825 Fire Fire Spell


local function MouseClicked(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 and ToolEquipped == true or input.KeyCode == Enum.KeyCode.ButtonR2 and ToolEquipped == true then
		local character = tool.Parent
		local Viewmodel = character:FindFirstChild("ViewportHands")
		
		local V_animation = Instance.new("Animation")
		V_animation.AnimationId = "rbxassetid://93767212783032"
		
		local V_Humanoid = Viewmodel:WaitForChild("Humanoid")
		local V_Animator = V_Humanoid:WaitForChild("Animator")
		
		local V_animTrack = V_Animator:LoadAnimation(V_animation)

		if Viewmodel then
			local Spell = Viewmodel:FindFirstChild("Spell")
			if Spell then
				local Fire = Spell:FindFirstChild("Fire")
				print("CHECK")

				FireFire:FireServer(Fire.CFrame.Position, mouse.Hit.Position)
				V_animTrack:Play()
				
			end
		end
	end
end


local renderConnection

tool.Equipped:Connect(function() 


	ToolEquipped = true

	local Viewmodel = game.ReplicatedStorage.ViewportSetup.ViewportHands:Clone() 
	local Camera = game.Workspace.CurrentCamera 
	local Character = tool.Parent
	local Head = Character:FindFirstChild("Head") 
	local LeftArm = Character:FindFirstChild("Left Arm")
	local RightArm = Character:FindFirstChild("Right Arm")
	local Torso = Character:FindFirstChild("Torso") 
	local SpellEquipped = false 
	local Humanoid = Character:FindFirstChild("Humanoid") 
	local V_LeftArm = Viewmodel["Left Arm"]
	local V_RightArm = Viewmodel["Right Arm"]
	local V_Humanoid = Viewmodel:WaitForChild("Humanoid") 
	local V_Animator = V_Humanoid:WaitForChild("Animator") 
	local Spell = Viewmodel:FindFirstChild("Spell")
	local Fire = Spell:FindFirstChild("Fire")

	Viewmodel.Parent = Character 
	local V_animation = Instance.new("Animation") 
	V_animation.AnimationId = "rbxassetid://74624677164025" 
	local V_animTrack = V_Animator:LoadAnimation(V_animation)
	V_animTrack:Play()

	local BC = game.ReplicatedStorage.AvatarSetup.WizardStuff

	if BC then
		local BC_Clone = BC:Clone()
		BC_Clone.Parent = Viewmodel
	end

        Fire.ParticleEmitter.Enabled = true
   
	Viewmodel.Parent = Character
	if LeftArm and RightArm then
		LeftArm.LocalTransparencyModifier = 1
		RightArm.LocalTransparencyModifier = 1
	end

	if renderConnection then
		renderConnection:Disconnect()
	end

	renderConnection = RunService.RenderStepped:Connect(function()

		if ToolEquipped then

			for i, part in pairs(Viewmodel:GetDescendants()) do
				if part:IsA("BasePart") or part:IsA("MeshPart") then
					part.LocalTransparencyModifier = 0
				end
			end

			local swayY = math.sin(tick() * 2) * 0.1
			local swayX = math.cos(tick() * 2) * 0.1
			Viewmodel:PivotTo(Camera.CFrame * CFrame.new(swayX, -4.5 + swayY, -1))
		end

	end)


	tool.Unequipped:Connect(function ()
		ToolEquipped = false

		Viewmodel:Destroy()
		renderConnection:Disconnect()
	end)
end)


UIS.InputBegan:Connect(MouseClicked)

--74624677164025

also if particles don’t work for viewmodels is there any way to do this?

or would there be any alternatives?

have u tried parenting the particle emitter inside a part inside a “WorldModel” instance and put that world model inside the viewportframe?

1 Like

Its a viewmodel, and it uses a local script to enable it, the thing is you can’t really simulate a particle emitter being parented to workspace with the said particle emitter actually emitting.