Hi, I am getting a error, it says that rightVector can't be assigned to. Any help?
script.Parent.Parent.Touched:connect(function(h) script.Parent.Parent.CFrame.rightVector = h.CFrame.rightVector end)
Try this, perhaps. This should take only the rotation of part h
and apply it.
script.Parent.Parent.Touched:connect(function(h) local hCFrameRotationOnly = h.CFrame - h.CFrame.p script.Parent.Parent.CFrame = hCFrameRotationOnly + script.Parent.Parent.CFrame.p end)
RightVector is a read-only value, and thus cannot be changed. Something like this might help instead:
script.Parent.Parent.Touched:Connect(function(h) local pos = script.Parent.Parent.Position local lookAt = pos + h.CFrame.lookVector script.Parent.Parent.CFrame = CFrame.new(pos,lookAt) end)
Hey LennonLight,
local part = script.Parent; -- The part local parts_to_not_touch = { -- Dictionary with the names of the parts that it shouldn't react towards. ["Baseplate"] = true; } part.Touched:Connect(function(obj) -- Declares an anonymous function connected to a Touched event. if not parts_to_not_touch[obj.Name] then -- If statement checking if the obj's name isn't any stored in the table, so it can prevent reactions to those parts. part.CFrame = CFrame.new(part.Position, obj.Position); -- Changes the CFrame by keeping the part's original position and sets the direction that the part is facing to the object that it touched. end -- end for the if statement end) -- end for the function