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

Pet Script positioning/rotating problems?

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		--
		local firefly = Instance.new("Part", game.Workspace)
		firefly.Size = Vector3.new(2,2.4,2)
		firefly.Transparency = 0.5
		firefly.CanCollide = false
		firefly:BreakJoints()
		firefly.Name = plr.Name .. "'s Firefly"
		--
		local bp = Instance.new("BodyPosition", firefly)
		bp.maxForce = Vector3.new(math.huge,math.huge,math.huge)
		
		--
		while wait() do
			bp.position = Vector3.new(char.Torso.Position.X,char.Torso.Position.Y -1,char.Torso.Position.Z +4)
			if char.Humanoid.Health < 1 then
				firefly:remove()
			end
		end
	end)
end)

So this scripts creates a brick and it follows the player, however it always seems to follow on the same axis (hard to explain) and never rotates with the player(so how would I do that). Also how would I make It so this brick always pings back to the right side of the player? would I create a brick that is welded to the player to the right so the brick has a target position? I don't know , any help would be much appreciated thanks :)

1 answer

✓ Accepted answer

This is a snippet from my own pet script I have, maybe this will help.

local bg=Instance.new("BodyGyro", v)
bg.MaxTorque=Vector3.new(math.huge,math.huge,math.huge)
local bp=Instance.new("BodyPosition", v)
bp.MaxForce=Vector3.new(math.huge,math.huge,math.huge)
while rs:wait() do --game:GetService("RunService").RenderStepped
	bp.Position=player.Character.Head.CFrame*CFrame.new(2,.5,0).p
	bg.CFrame=player.Character.Head.CFrame
	bg.CFrame=bg.CFrame*CFrame.Angles(0,0,0)
	bp.D=515
end

2 comments

0

thanks man! this actually helped more than you'd think ahah, much appreciated!

0

No problem. It was most likely the absence of BodyGyro, which made the rotation all wacky, lol.

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