I’m trying to make a baseball that hurts you when you get hit with it, but it isn’t detecting the touch event. I don’t know if I’m doing something stupid or there’s something wrong with roblox. Any help is appreciated.
script.Parent:WaitForChild("RemoteEvent").OnServerEvent:Connect(function(player, mouse)
local part = script.Parent:WaitForChild("Handle"):Clone()
part.Name = "item"
part.Parent = game.Workspace
part.Position = player.Character:WaitForChild("RightHand").Position
local speed = 500
part.CFrame = CFrame.new(player.Character:WaitForChild("RightHand").Position, mouse)
part.Velocity = part.CFrame.LookVector * speed
part.Touched:Connect(function(hit)
local hitParent = hit.Parent
local h = hitParent:FindFirstChild("Humanoid")
if h then
h.Health = 0
end
end)
script.Parent:Destroy()
end)