So, in my workspace, I have a part that looks like this:
Part - Script - BodyVelocity
The script looks like this:
Boop = script.Parent function sayhi() print("bruh") end Boop.Touched:Connect(sayhi)
When I run the game, the part looks like this:
Part - Script - TouchInterest - BodyVelocity
The original part works as intended, but when my gun clones the Part to shoot it out, it doesn't copy the touchinterest meaning that my script can't print "bruh" because it can't detect when it is touched.
How do I get the touchinterest to be cloned as well?
If you want to clone a part I'd put it in ReplicatedStorage
, that's what the storage is for. Also you can put the .Touched
function inside of where your gun clones the part like so:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local shootingPart = ReplicatedStorage:WaitForChild("Part") --// In your shooting function after you clone the part local clone = shootingPart:Clone() clone.Parent = workspace clone.Touched:Connect(function() print("bruh") end)
or for the code above to be shorter since the "short cuts" are not needed
local shootingPart = game.ReplicatedStorage:WaitForChild("Part") shootingPart:Clone().Parent = workspace shootingPart.Touched:Connect(function() print("bruh") end)
we dont need all those shortcuts so i narrowed it down to a shorter code, does the exact same thing though