How to detect a locally Cloned Part?

I am having a hard time detecting cloned objects. I want to have a bomb that falls from the sky and if it hits a part, it makes a new explosion at that location.

I have a local script that clones this bomb and puts it into the workspace above the map. When it hits the buildings, it does nothing. I have tried it without it being local and it works, so I think the main problem is it being local.

Here is the script, it looks normal to me but does it have to do something with it being local?

script.Parent.Touched:Connect(function()

print(“Touched”)

local explosion = Instance.new(“Explosion”)

explosion.Position = script.Parent.Position

explosion.Parent = script.Parent

script.Parent:Destroy()

end)

Does anyone know how to fix this?

.Touched event does not replicate to clients.
Sorry it actually does

Also why do you need to make it local?

I am tracking where the players mouse is so when they click the part spawns where they clicked.

Is there a way I can track their mouse with server script?

No. rucufbvfjghjfjvnfugbfufbdurgd

https://developer.roblox.com/en-us/api-reference/event/Instance/ChildAdded
https://developer.roblox.com/en-us/api-reference/event/Instance/DescendantAdded

You can check when an instance receives a new instance parented to it using the above functions.

script.Parent.ChildAdded:Connect(function(child)
	--do stuff with recently added child
end)

You can do the tracking on the client and use a RemoteEvent when you click, so it would actually show up for other players.

I just read further, to detect parts touching one another you’ll need to make use of a Touched event. You should receive the part which fires the event as a parameter to the connected the function.

https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched

localscript can not run directly on workspace

1 Like