this script inside a block that should make a nuke move if a part named "icecube" touches the scripts parent, but if i just step on it, it activates too, only the ice cube should be activating it!!
01 | local part = script.Parent |
02 | local otherPart = game.Workspace.icecube |
03 |
04 | local function onPartTouched(otherPart) |
05 | game.Workspace.SBSun:MoveTo(Vector 3. new(- 249.346 , 7.379 , - 183.227 )) |
06 | game.Workspace.BOOM.Playing = true |
07 | wait( 3.265 ) |
08 | game.Workspace.BOOM.Playing = false |
09 | game.Workspace.BOOM.TimePosition = 0 |
10 | game.Workspace.SBSun:MoveTo(Vector 3. new(- 9999.444 , 3800 , - 3343434 )) |
11 | end |
12 |
13 | part.Touched:Connect(onPartTouched) |
the nuke is spawning above the block, but the block is like in the middle of the room, in the air, so the nuke might not have room?? how do i get it to spawn in the middle of the room, and not above the ceiling?
You are not checking for the "icecube" part, which is why anything can activate the nuke.
As for the position that your nuke spawns, if the script's parent is in the spot you want the nuke to spawn in, you could set the script's parent's positiont to:
1 | local part = script.Parent |
2 |
3 | --... |
4 |
5 | NUKE:MoveTo(part.Position) -- replace "NUKE" with correct location |
Script:
01 | local part = script.Parent |
02 | local icecube = game.Workspace.icecube |
03 |
04 | local function onPartTouched(otherPart) |
05 | if otherPart = = icecube then -- check for specific part |
06 | game.Workspace.SBSun:MoveTo(Vector 3. new(- 249.346 , 7.379 , - 183.227 )) |
07 | game.Workspace.BOOM.Playing = true |
08 | wait( 3.265 ) |
09 | game.Workspace.BOOM.Playing = false |
10 | game.Workspace.BOOM.TimePosition = 0 |
11 | game.Workspace.SBSun:MoveTo(Vector 3. new(- 9999.444 , 3800 , - 3343434 )) |
12 | end |
13 | end |
14 |
15 | part.Touched:Connect(onPartTouched) |