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

Script not triggered when something moved to Workspace? Bit complicated...

So, i'm working on a tycoon. And i want the next thing to happen.

If a model is moved from for exmaple Lighting, to workspace. And in that model is a brick named "MuurDestroyer". If that brick touched a other brick named wall, which is in a different model, that the wall is being :Destroy()

This is what i've tried:

wait()
wait(3)
Debounce = false
script.Parent.Touched:connect(function(hit)
	print("Hit")
	if Debounce then return end
	if hit.Name == "MuurDestroyer" then
		print("Hit2")
		Debounce = true
		wait(1)
		for i=0,1,0.05 do
			wait()
			script.Parent.Transparency = i
		end
		wait()
		script.Parent.Transparency = 1
		wait(1)
		script.Parent:Destroy()
		Debounce = false
		
	end
end)
(This script is in the wall)

This script should be triggered when the model with "MuurDestroyer" is being moved to workspace.

So. The problem is:

Touch:Connect does not register the Ontouch when the model is moved from Lighting to Workspace. The model litterly 'spawns' in front of the Brick, and touches it, but it doesn't register the Ontouch...

5 comments

0

Remove the wait()'s at the top of the script. I can tell you've been watching AlvinBlox, who is literally the worst scripter on YouTube.

0

You dont need the wait, you dont need to setect the ancestory changed, and you dont need the wait at the beginning.

0

I didn't watch any video :-).

0

Then what is up with the wait()'s? You don't need them. They are entirely irrelevant.

0

I thought the wait would help with lowering the pressure on your servers

1 answer

I suggest just doing this in a server script under the part that can be touched: (By that I mean what gets destroyed by the wall, not the wall)

script.Parent.Touched:Connect(function(obj)
	if obj.Name == "MurrDestroyer" then
		--Code when it touches wall here
	end
end)

This is a lot quicker, easier, and more compact. It will do the same thing.

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