You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want a ParticleEmitter to start while the part is being touched, and stop when it isn’t
-
What is the issue? Include screenshots / videos if possible!
n/a
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried tutorials, but because i’m new to scripting I can’t get it to work
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
The emitter shouldn’t start when clicked, only when physically touched
--script should be in part
--particleEmitter should also be in part
local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA('Humanoid') then
part:FindFirstChildWhichIsA('ParticleEmitter').Enabled = true
end
end)
NOT BUG TESTED
Edit: fixed a few typos
replying to this post: yes
Thanks, let me try it, i’ll let you know how it goes in a second
should the script be placed like this?
Doesn’t look like it works, no errors came up in studio though
Why is the script in the image disabled?
Oh i have a plugin that disables scripts automatically, i think i forgot to disable it
The emitter doesn’t shut off when i step off the part
But the part turns on correctly
Ok, so use a part.TouchEnded:Wait()
and the end
Ex:
local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA('Humanoid') then
part:FindFirstChildWhichIsA('ParticleEmitter').Enabled = true
part.TouchEnded:Wait()
part:FindFirstChildWhichIsA('ParticleEmitter').Enabled = false
end
end)
Works perfectly! thanks so much!
1 Like