New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
0

Making a morph script, but the part rotates differently everytime I trigger the script?

Edited 11 months ago

I'm trying to make a brick part of the character appearance, but it rotates differently everytime I trigger the script. How do I get it to not rotate differently everytime I trigger the touch event?

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
else
newPart.Parent = hit.Parent
local weld = Instance.new("ManualWeld")
weld.Part0 = newPart
end
end
end)



1
sleazel 759
11 months ago
Edited 11 months ago

Replace:

newPart.CFrame = CFrame.new(hit.Parent:FindFirstChild("Head").Position)


with:

newPart.CFrame = hit.Parent:FindFirstChild("Head").CFrame


If your part in ScriptStorage is not positioned properly, you may still the get it wrong, but it will be wrong always the same. Consider this code, replacing x,y,z and r with proper values or repositon CFramePrimaryPart in ServerStorage.

newPart.CFrame = (hit.Parent:FindFirstChild("Head").CFrame  + Vector3.new(x,y,z)) * CFrame.Angles(0,math.rad(r),0)


Also consider adding debounce, to avoid having a multiple masks on one character.

0
It doesn't rotate anymore, but it positions itself differently now. Depanding on where I touch the part. Gameplay28 69 — 11mo
0
I have checked the code with random mask from library, it works. Weird. Maybe your HazmatMask model is bad. sleazel 759 — 11mo
0
It doesn't do this till I add to the Vector3 value. Gameplay28 69 — 11mo
0
I may be overcomplicating things. Is your HazmatMask made of a single part with mesh? sleazel 759 — 11mo
0
No, It's a union, could that be the reason it's not working? Gameplay28 69 — 11mo
0
Alright, I tested it with a normal part and it works. So I guess it is because of it being a union. Gameplay28 69 — 11mo
0
Is there a way it could work with a union? Gameplay28 69 — 11mo
0
Sorry, i don't know. I am not really using the unions. Try creating invisible, non collidable block in the middle and weld the union to it. Then make a union as a child of this part, and CFrame only this part. sleazel 759 — 11mo
0
Smart thinking, I'll try it. Gameplay28 69 — 11mo
0
Thanks a lot with helping, I did what you did but with a head. So I wouldn't have to change the vector value. Gameplay28 69 — 11mo