i want to make a part that when the player touches it the part will shoot out a bunch off particles how would i do this?
i alredy know how to do the particle part but not the scripting part
i want to make a part that when the player touches it the part will shoot out a bunch off particles how would i do this?
i alredy know how to do the particle part but not the scripting part
So you could use a simple .Touched event connected to said part (with a debounce) and then either Enable particles or use Particle:Emit(numofparticles)
Here’s an example.
local lastActivate = 0
local cooldown = 2
part.Touched:Connect(function()
if os.clock() - lastActivate >= cooldown then
lastActivate = os.clock()
particles:Emit(100)
end
end
how would i choose what particle it emits like could i make when and then reference it in the script?
create a variable that points to said particle
like lets say a particle named epicparticles is located in a part named dog in workspace.
you could create a variable that points to it like this.
local particle = game.Workspace.dog.epicparticles
ok let me try this
btw where would i put this script like serverscriptservice or what
you could just put this inside of the model with the part. it would make it easier to reference the part with the particle in it.
local part = script.Parent.Part
local particle = script.Parent.Particle
example of what i mean ^
ok im trying it now also would it be a local script?
no. wont run on a local script.
it didnt work so a few things
does the particle emiter have to be enabled?
also heres the workspace
script is the script to play the parrticles
heres the script i put
local part = script.Parent.Part
local particle = script.Parent.Particle
local lastActivate = 0
local cooldown = 2
part.Touched:Connect(function()
if os.clock() - lastActivate >= cooldown then
lastActivate = os.clock()
particle:Emit(100)
end
end
Okay so I simply showed an example of how you would implement this. What you need to do is just move the script so the parent of the script is TouchableModel. Then you need to change variables to match the names of the parts and particles.
local part = script.Parent.Part wont work because there is nothing named part.
local part = script.Parent.Union -- will work because Union is a valid member of TouchableModel.
local particle = script.Parent.Particle -- wont work because nothing is named part plus its not inside of the model its inside of Union.
local particle = part.ParticleEmitter -- using the correct variable to reach ParticleEmitter.
local Particle = game:GetService("ServerStorage"):WaitForChild("ParticleEmitter") -- assuming you put the particle emitter in serverstorage
local Part = script.Parent
local Connection = Part.Touched:Connect(function()
Particle:Clone().Parent == Part
end)
Connection:Disconnect() -- makes sure it only happens once
let me try this would i have to move the particle emmiter to serverstorage?
(edit now i see that i have to put it in the storage
hmm stil not working the error says that line 5 is a incomplete statment exected assignment or function call
local Particle = game:GetService("ServerStorage"):WaitForChild("ParticleEmitter") -- assuming you put the particle emitter in serverstorage
local Part = script.Parent
local Connection = Part.Touched:Connect(function()
local ParticleClone = Particle:Clone()
ParticleClone.Parent = Part
end)
Connection:Disconnect() -- makes sure it only happens once
hmmm stil not working i dont know why
You can listen to when a player has touched the part using TouchedEvent
, then simply clone a ParticleEmitter
(or create it using instance.new
) and parent it to the part.
Have you even attempted to learn scripting on Roblox before undertaking this? Have you tried to script it on your own? The dev forum is not a place to be given scripts by people. It’s to receive help and feedback if something isn’t working.
First off, put a ParticleEmitter inside your part: (make sure it’s not enabled)
(also add a script inside)
In the script paste this:
--//Services
local Players = game:GetService("Players")
--//Variables
local Part = script.Parent
local ParticleEmitter = Part.ParticleEmitter
--//Controls
local debounce = false
local debounce_wait = 0.5
--//Functions
Part.Touched:Connect(function(hit)
if debounce then
return
end
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
debounce = true
ParticleEmitter:Emit(100)
task.delay(debounce_wait, function()
debounce = false
end)
end
end)
If it doesn’t work, check out this placefile for reference:
ParticleEmitters.rbxl (37.7 KB)