Touched event not firing

I have tried multiple ways to get around this issue but no luck.

local player = workspace.Player
local hitbox = script.Parent

script.Parent.Touched:Connect(function(P)
  print("Touch detected.")
     if P.Parent == workspace.EnemyProjectiles then
     print("Death.")
     local newPlayer = player:Clone()
     player:Destroy()
     script.Death:Play()
     wait(3)
     newPlayer.Parent = workspace
  end
end)

The prints do not run at all.
hitbox is a welded part, the projectiles are anchored parts that use cframe to move.
Any idea why this issue is happening?

Can we see a screenshot of the explorer.

Sure.

image

Are you moving them locally or on the sever

Im moving them via a localscript.

That’s the problem. If you are moving them on the client the sever doesn’t know that their in their new position therefore a Server script won’t detect the hit

Well… is there any ways to get around this using clientside?

Since im using renderstepped and a server movement system could result in jittery movement i would like to know if theres a way.

You can probably use a RemoteFunction to get the client sided position of the part. However, that doesn’t sound very safe.

Like @FunAsiK said if you use:

When moving in the server so it’s not jittery

Use SetNetworkOwner() on the projectiles.

Would that work on anchored parts?

No. SetNetworkOwner() does not work on anchored parts.

Well… im using anchored parts, since im out of ideas im assuming that i have to create projectiles via a script.

Other than that i have a few questions: do RemoteEvents affect performance,
Is there a way to move a projectile via physics without it falling down?

How would I do it.

  1. If projectile not a model, then make it as a model and set PrimaryPart to projectile.

  2. Create a fake part.

local part = Instance.new("Part")
part.Name = "FakePart"
part.CanCollide = false
part.Anchored = true
part.Size = Vector3.one
part.Transparency = 1
part.CFrame = CFrame.new()
part.Parent = projectile_model
  1. Add Align Position and Align Orientation to make movement smooth.
local projectile_attachment = Instance.new("Attachment", projectile_model.PrimaryPart)
projectile_attachment.Name = "ProjectileAttachment"

local fake_part_attachment = Instance.new("Attachment", part)
fake_part_attachment.Name = "FakePartAttachment"


local align_pos = Instance.new("AlignPosition", projectile_model.PrimaryPart)
align_pos.Attachment0 = projectile_attachment
align_pos.Attachment1 = fake_part_attachment
align_pos.MaxForce = 1e11
align_pos.MaxVelocity = 100
align_pos.Responsiveness = 15


local align_orientation = Instance.new("AlignOrientation", projectile_model.PrimaryPart)
align_orientation.Attachment0 = projectile_attachment
align_orientation.Attachment1 = fake_part_attachment
align_orientation.MaxTorque = 1e11
align_orientation.MaxAngularVelocity = 100
align_orientation.Responsiveness = 15
  1. Update the CFrame of the FakePart in RunService.RenderStep or while true do.
while true do
    part.CFrame = -- your's CFrame.
    wait()
end
  1. And now you can use SetNetworkOwner().
workspace:WaitForChild("ProjectileModel").PrimaryPart:SetNetworkOwner(nil)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.