local Hitbox = Instance.new("Part",workspace.VFxFolder)
Hitbox.Material = Enum.Material.ForceField
Hitbox.Size = Vector3.new(5,5,raycastresult.Distance)
Hitbox.CanCollide = false
Hitbox.Anchored = true
Hitbox.CFrame = CFrame.new((Origin + raycastresult.Position)/2,Origin)
Hitbox.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
if part.Parent.Name ~= character.Name then
character:PivotTo(part.Parent.PrimaryPart.CFrame * CFrame.new(0,0,-3))
end
else
character:PivotTo(CFrame.new(raycastresult.Position) + Vector3.new(0,2,0))
end
end)
This is my script
Basically I want to teleport at behind player when player hit hitbox but if not then teleport to mouse position
GL0XBE
(globe)
May 3, 2024, 9:50am
#2
You do realize the touched event fires whenever something touches it right?
Then How to detect if part touch another part but not humanoid
LLukasVx
(Lukas)
May 3, 2024, 10:11am
#4
The touched event wil trigger whenever something is touched, it doesn’t need to be a character. If you wanna trigger something whenever a part is hit just use the touched funtion.
script.Parent.Touched:Connect(function()
end)
cakeycocoa
(StarvinMarvin)
May 3, 2024, 10:29am
#5
Check the hit’s type.
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then return end
end)
OK I could just use Spherecast
system
(system)
Closed
May 17, 2024, 11:31am
#7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.