[SOLVED] Particles on Screen (Like GPO's previous one)

Ok, i’ll be waiting for it. Also I put the script in local script

Ok, so from doing some basic division math out of the blue. I figured that the box’s X size should be Workspace.Camera.ViewportSize.X.Value/257. While the Y value should be Workspace.Camera.ViewportSize.Y.Value/226.71

if we’re using the raw ViewportSize value the part size would be too big, so to scale it like normal part size we can use ViewportSize.Unit

wait, but the /257 and /226.71 is kinda working. and how do we use the ViewportSize.Unit thing?

oh wait nvm, that also works the same

I’ve updated the module and fixed the part scaling

Thanks. That’s very nice of you. I was sitting there thinking how i could move the particles to the right place and my brain just got stuck thinking what math i should use for it

(once again updated the modules, only thing i added is that the particle will cover most of the missing area now (i also would recommend to use the id of the module instead for updates))

I think i’ll use my own from now on. I modified yours into something i prefer, i also added some attachments to cover the missing spots

local RunService = game:GetService("RunService")
local module = {}

function module:Start(Particle:ParticleEmitter)
	if Particle and Particle:IsA("ParticleEmitter") then
		self.CurrentParticle = Particle.Name
		local Overlay = script.Overlay:Clone()
		Overlay.Parent = workspace.CurrentCamera
		Overlay.Name = self.CurrentParticle .. "_Overlay"

		for i,v in pairs(Overlay:GetChildren()) do
			local Particle_C = Particle:Clone()
			Particle_C.Parent = v
			Particle_C.Enabled = true
			Particle_C.LockedToPart = true
		end

		RunService:BindToRenderStep(self.CurrentParticle,10000,function()
			local Xe = game.Workspace.Camera.ViewportSize.X
			local DistFromCam = 1.3
			local Ye = game.Workspace.Camera.ViewportSize.Y
			Overlay.Size = Vector3.new(Xe/257, Ye/226.71, 0.506)
			Overlay.CFrame = workspace.CurrentCamera.CFrame*CFrame.new(0,0,0)
			Overlay.X.WorldCFrame = Overlay.CFrame * CFrame.new(Overlay.Size.X/2.3,-Overlay.Size.Y/9.2,-DistFromCam)
			Overlay.Xi.WorldCFrame = Overlay.CFrame * CFrame.new(-Overlay.Size.X/2.3,-Overlay.Size.Y/9.2,-DistFromCam)
			Overlay.Xsi.WorldCFrame = Overlay.CFrame * CFrame.new(-Overlay.Size.X/4.6,-Overlay.Size.Y/2.3,-DistFromCam)
			Overlay.Xsii.WorldCFrame = Overlay.CFrame * CFrame.new(-Overlay.Size.X/2.3,-Overlay.Size.Y/2.3,-DistFromCam)
			Overlay.Xsiii.WorldCFrame = Overlay.CFrame * CFrame.new(Overlay.Size.X/4.6,-Overlay.Size.Y/2.3,-DistFromCam)
			Overlay.Xs.WorldCFrame = Overlay.CFrame * CFrame.new(Overlay.Size.X/2,Overlay.Size.Y/2.3,-DistFromCam)
			Overlay.Y.WorldCFrame = Overlay.CFrame * CFrame.new(0,Overlay.Size.Y/2.3,-DistFromCam)
			Overlay.Yi.WorldCFrame = Overlay.CFrame * CFrame.new(0,-Overlay.Size.Y/2.3,-DistFromCam)
			Overlay.Ys.WorldCFrame = Overlay.CFrame * CFrame.new(-Overlay.Size.X/2.3,Overlay.Size.Y/2.3,-DistFromCam)
			Overlay.Ysi.WorldCFrame = Overlay.CFrame * CFrame.new(Overlay.Size.X/2.3,-Overlay.Size.Y/2.3,-DistFromCam)
			Overlay.Ysii.WorldCFrame = Overlay.CFrame * CFrame.new(Overlay.Size.X/4.6,Overlay.Size.Y/2.3,-DistFromCam)
			Overlay.Ysiii.WorldCFrame = Overlay.CFrame * CFrame.new(-Overlay.Size.X/4.6,Overlay.Size.Y/2.3,-DistFromCam)
			Overlay.Ysiiii.WorldCFrame = Overlay.CFrame * CFrame.new(Overlay.Size.X/2.3,Overlay.Size.Y/9.2,-DistFromCam)
			Overlay.Ysiiiii.WorldCFrame = Overlay.CFrame * CFrame.new(-Overlay.Size.X/2.3,Overlay.Size.Y/9.2,-DistFromCam)
		end)
	else
		warn("Invalid input for Particle [Particle does not exist / not a particle]")
	end
end

function module:Stop()
	if self.CurrentParticle then
		local Overlay = workspace.CurrentCamera:FindFirstChild(self.CurrentParticle .. "_Overlay")
		
		if Overlay then
			for i,v in pairs(Overlay:GetChildren()) do
				v:FindFirstChild(self.CurrentParticle).Enabled = false
			end
			game.Debris:AddItem(Overlay,1.5)
		end
		
		RunService:UnbindFromRenderStep(self.CurrentParticle)
	end
end

return module

2 Likes

thanks for improving the script!, I’ll use that script for the module

Your Welcome. I should be thanking you for helping me from the start, all i did was modify your script.

for some reason, the particles won’t always fully show on the screen for me if I go in game vs in studio and idk why

Studio : RobloxStudioBeta_r1cwaWPFlP.mp4
In Game: RobloxPlayerBeta_5g2slr60pS.mp4

I think i missed something…could you help??

I tried his module and yours.

1 Like

I’m not sure how to fix this actually. Could you try experimenting with it such as resizing the game window screen to see if it makes a difference? Because this is made to auto scale with game window screen and resolution using Viewport size. I think Viewport Size could be the problem. Could you try it out?

yea i was experimenting with different devices with the emulator feature in studio and it was all over the place. I was wondering if it was because of the particle or something? like should i have certain particle settings or something?

Iphone : RobloxStudioBeta_cbLwSfoYKK.mp4
Xbox One : RobloxStudioBeta_MNTsc2pCv8.mp4
Samsung Tab: RobloxStudioBeta_ZjVEG4BXOx.mp4

yea so i wouldnt know wat to do since i didnt make the script and its doing alot of complicated calculations that I wouldn’t really understand.

are you guys having this issue as well or is it just me?

I haven’t tried it out in main game. I haven’t planned on doing so since I made the post, the project was to make a simple burn damage system. It succeeded and left it alone for a long time. I’m not sure what to do, I hadn’t thought of a solution so far. If I do find a solution I’ll let you know.

oh thats alright. I made my own version that works perfectly for my game! Thx anyway.

Can I ask how you did it? I’m curious on the solution, I actually couldn’t think of why the problem was occurring at all

How do I modify it to work with attachments? more details here.