|
| 20 Aug 2016 06:05 PM |
As the brick touches the grass it emits particles but when it is not hitting grass the particles stop. That is my goal for this script, I have been looking through other scripts and I'm kinda confused how to do this. Also I'm think your going to need a looping part to always check if it is hitting "Grass"
So far I have this.
function onTouched(Hit) if Hit.Name == "Grass" then script.Parent.Touch.Value = true
if script.Parent.Touch.Value == true then script.Parent.ParticleEmitter.Enabled = true end
if script.Parent.Touch.Value == false then script.Parent.ParticleEmitter.Enabled = false end
end end script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
r2go
|
  |
| Joined: 20 Oct 2011 |
| Total Posts: 88 |
|
|
| 20 Aug 2016 06:33 PM |
This might work? You might need to change the < and > signs around, but this should work.
local GroundPos = workspace.[whehereberthegroundis].Position local GroudSize = Ground.Size local AllGround = (GroundSize/2)+GroundPos
function onTouched(Hit) if Hit == "Grass" then repeat if AllGround >= script.Parent.Touch.Position then script.Parent.Touch.Value = true script.Parent.ParticleEmitter.Enabled = true elseif AllGround <= script.Parent.Touch.Position then script.Parent.Touch.Value = false script.Parent.ParticleEmitter.Enabled = false until x = 0 end script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 06:54 PM |
This is not working... :/
local GroundPos = workspace.[whehereberthegroundis].Position
Do I need to put something here? If so, what? --^ |
|
|
| Report Abuse |
|
|
r2go
|
  |
| Joined: 20 Oct 2011 |
| Total Posts: 88 |
|
|
| 20 Aug 2016 07:52 PM |
Yeah so I messed up four times here, sorry I messed up so much. :P
First thing is
local GroundPos = workspace.[whehereberthegroundis].Position
I don't know where your ground is located so make a directory to where it is located like "workspace.ground.Position"
Second thing is
Where I put local "AllGround = (GroundSize/2)+GroundPos"
do this
AllGround = (GroundSize/2)+GroundPos + Vector3.new(2,2,2)
Third thing is here(it appears twice in your script) "if AllGround >= script.Parent.Touch.Position then"
Change it to "if AllGround >= script.Parent.Position then"
Fourth thing is add a "wait()" somewhere in the repeat |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 08:01 PM |
until x = 0
I get a red line under "until" |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 08:03 PM |
while wait() do local enabled = false for _,v in pairs(script.Parent:GetTouchingParts()) do -- if blah then enabled = true end end
--do stuff if enabled end
OR
script.Parent.Touched:connect(function()
end)
script.Parent.TouchEnded:connect(function()
end) |
|
|
| Report Abuse |
|
|