Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Nuke isnt spawning in right place and activates when anything touches it??

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!!

local part = script.Parent
local otherPart = game.Workspace.icecube

local function onPartTouched(otherPart)
	game.Workspace.SBSun:MoveTo(Vector3.new(-249.346, 7.379, -183.227))
	game.Workspace.BOOM.Playing = true
	wait(3.265)
	game.Workspace.BOOM.Playing = false
	game.Workspace.BOOM.TimePosition = 0
	game.Workspace.SBSun:MoveTo(Vector3.new(-9999.444, 3800, -3343434))
end

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?

1 answer

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:

local part = script.Parent

--...

NUKE:MoveTo(part.Position) -- replace "NUKE" with correct location

Script:

local part = script.Parent
local icecube = game.Workspace.icecube

local function onPartTouched(otherPart)
	if otherPart == icecube then -- check for specific part
		game.Workspace.SBSun:MoveTo(Vector3.new(-249.346, 7.379, -183.227))
		game.Workspace.BOOM.Playing = true
		wait(3.265)
		game.Workspace.BOOM.Playing = false
		game.Workspace.BOOM.TimePosition = 0
		game.Workspace.SBSun:MoveTo(Vector3.new(-9999.444, 3800, -3343434))
	end
end

part.Touched:Connect(onPartTouched)

3 comments

0

Where does the 5-lined script go into the larger script? Does the NUKE:MoveTo go outside local function?

1

You would put NUKE:MoveTo in the line that moves your nuke into the 'room'. Because your Nuke isn't named 'nuke' in your code, I can only assume that SBSun is your nuke. You would just replace line 6's position with part.Position.

0

ok

This discussion is preserved as it was. New answers, comments, and votes are closed.