I am trying to make a part move when it is touched by a player. I want the part to go in the direction that the player is facing. I have looked into how I do this but I can’t find a solution. How do I accomplish this?
1 Like
Apply a vector force to the part with the direction of HumanoidRootPart.CFrame.LookVector
I made a way to do it but when I do it the ball goes straight there (teleports). How do I make it tween there.
local part = script.Parent
local function onTouch(hit)
local character = hit.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
local direction = character:GetPrimaryPartCFrame().lookVector
local speed = 10 -- Speed setting
part.CFrame = part.CFrame + direction * speed
end
end
part.Touched:Connect(onTouch)
You could use :Lerp to make the ball not teleport.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.