function Touch(hit)
hit.Parent.Position = hit.Parent.Position + Vector3.new(-10,0,0)
end
I need it player touch Part he is move. Why it isn’t works?
function Touch(hit)
hit.Parent.Position = hit.Parent.Position + Vector3.new(-10,0,0)
end
I need it player touch Part he is move. Why it isn’t works?
Hit.Parent in most cases would be a Model, and Models don’t have a Postion
property, so it would error, you’d have to get the HumanoidRootPart of the character. Also, it’s more recommended to change the Position via CFrame
instead of Position
function Touch(hit)
local char = hit.Parent
local rootPart = char:FindFirstChild("HumanoidRootPart")
if not rootPart then
return
end
rootPart.CFrame *= CFrame.new(-10,0,0)
end
script.Parent.Touched:Connect(function(Touch)