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)
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)
I should make some clerifications, I want it to only be the X Axis.
Clarifications*
Also, doesn't work
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
##I hope that I helped, and have a nice day.
###Thanks,
###~~ KingLoneCat
He doesn’t want to point the part to face the object that touched, but rather point the part in the same direction and have it face the same way as the object that touched.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Works thanks!