Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

i want a genie to be beside the player, but it's not moving the whole model?? (pls, i need it)

I've made like a game, about you can get these wishes from a genie. I want the genie to appear 2 studs beside me, but it's only moving the primarypart, not the whole model??

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local part = workspace.Genie.PrimaryPart -- I've already set the primarypart manually, so no need to worry

workspace.Genie:SetPrimaryPartCFrame(part.CFrame) -- setting the primary CFrame.

function setOffset(cframeX, head)
	return head.CFrame:ToWorldSpace(cframeX) -- basically sets an offset from the head according to the position regardless of rotation
end

wait(2) -- waits a bit, because sometimes it can cause errors like; attempt to index nil with head

game:GetService("RunService").RenderStepped:Connect(function() -- for every frame thats running it will trigger the code above the "end)"

    local newOff = setOffset(CFrame.new(0, 10, 0), character.Head) -- we fetch the offset
    part.CFrame = newOff -- setting the parts cframe to the offset according to the head.
	
	if not part.Massless then -- if the part has a mass

		part.Massless=true -- make the part weightless, so it won't affect the pressure on the player
		
	end
end) -- ends the code

1 answer

Try using attachments to the primary part, then move the part.

EDIT : For example, the model should have a part know as a HitBox that covers the entire body of the genie, set the HitBox as the primary part and add welds to all other parts of the model. Then you can make the HitBox move, and all other parts will follow.

Note : HitBox transparency should be set to 0 HitBox anchored should be false HitBox cancollide should be false HitBox should be a part The Part0 of all weld constraints should be HitBox All weld constraints should be in the HitBox

More help on HitBox

1 comment

0

Please elaborate, and i will accept.

This discussion is preserved as it was. New answers, comments, and votes are closed.