I am trying to get a part to print a message when it has been touched in a module script and nothing happens when it is touched. I tried making the module return the part back to the main script and have the event listener there but that strangely did not work.
I have seen and tried fixs from slightly different forum topics but none of them have worked.
Here is the code in the module:
local bullet = Instance.new("Part")
bullet.Material = Enum.Material.Neon
bullet.Size = Vector3.new(1,1,1)
bullet.CanCollide = false
bullet.CanTouch = false
bullet.Name = "Bullet"
bullet.CanQuery = false
bullet.Position = (MPos)
local Velocity = Instance.new("BodyVelocity")
Velocity.Velocity = LookVector * 400
Velocity.Parent = bullet
bullet.Parent = game.Workspace
return bullet
Here is the old code in the module when I was listening for the event there:
local bullet = Instance.new("Part")
bullet.Material = Enum.Material.Neon
bullet.Size = Vector3.new(1,1,1)
bullet.CanCollide = false
bullet.CanTouch = false
bullet.Name = "Bullet"
bullet.CanQuery = false
bullet.Position = (MPos)
local Velocity = Instance.new("BodyVelocity")
Velocity.Velocity = LookVector * 400
Velocity.Parent = bullet
bullet.Parent = game.Workspace
bullet.Touched:Connect(function()
print("touched")
end)
Here is the code in the main script:
local bullet = WeaponMod.Shoot(Weapon, player)
bullet.Touched:Wait()
print("touched")
I would appreciate assistance with this error.