Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Add effect to my viewmodel gun?

Asked by
VAnkata20 135
1 year ago

I am trying to make a fps game but while making it I realized something. I can't add a Particle emitter to the ViewportFrame. Does anyone know a way to add emitters or any kind of effect?

I also tried adding a visualizer for the RayCasting but again I can't find a way to sync position of the ViewModel and Mouse.

Here is the code for the visualizer

local Origin = ShootPart.WorldPosition
        local Direction = (Received.Position-Origin).Unit*3000
        local Raycast = workspace:Raycast(Origin,Direction)

        local Intersection = Raycast and Raycast.Position or Origin + Direction
        local Distance = (Origin - Intersection).Magnitude

        local Visualizer = Instance.new("Part")
        Visualizer.CanTouch = false
        Visualizer.CanCollide = false
        Visualizer.CanQuery = false
        Visualizer.CastShadow = false
        Visualizer.Anchored = true
        Visualizer.Material = Enum.Material.Neon
        Visualizer.Color = Color3.fromRGB(255, 255, 0)
        Visualizer.Size = Vector3.new(.15,.15,Distance)
        Visualizer.CFrame = CFrame.new(Origin, Intersection)*CFrame.new(0,0,-Distance/2)

        if Do.Visualize == true then
            Visualizer.Parent = workspace
            TweenService:Create(Visualizer,TweenInfo.new(.3),{Transparency = 1, Size = Vector3.new(0,0,Distance)}):Play()
            Debris:AddItem(Visualizer,.35)
        end

I looked at every documentary but still couldn't find an answer

Answer this question