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

How do I have a part displaced from the player?

Basically I need a part to be always 300 units away from the player on the +X axis, but when I try that part moves all jittery. Here's the code i'm using:

if script.Parent.Parent == workspace.Gamespace then
local RunService = game:GetService('RunService')
local countDownValue = 100

local function update()
	if script.Parent.Player.Value.Humanoid.Health < 1 then
		script.Parent:Destroy()
	end
	if script.Parent.Health.Value > 0 then
		local oldCFrame = script.Parent.Player.Value.HumanoidRootPart.CFrame
		oldCFrame = oldCFrame + Vector3.new(300,0,0)
		script.Parent.CFrame = oldCFrame
		script.Parent.Size = Vector3.new(3,3,3)
		if script.Parent.Position.Z < 84 then
			script.Parent.Transparency = 1
		else
			script.Parent.Transparency = 0
		end
	else
		countDownValue = countDownValue - 0.5
		script.Parent.Size = Vector3.new((countDownValue/100)*3,(countDownValue/100)*3,(countDownValue/100)*3)
		script.Parent.Transparency = 1-(countDownValue/100)
		if countDownValue < -150 then
			script.Parent.Anchored = true
			script.Parent.Health.Value = 100
			countDownValue = 100
		end
	end
end

RunService.Stepped:Connect(function(step)
	pcall(update)
end)
end

(This script would be inside the part being moved, and script.Parent.Player is an ObjectValue that contains the player character)

1 answer

well you can do something like this:

local RunService = game:GetService("RunService");

local part = ---part to display
local player = --the player

RunService.Stepped:Connect(function()
	local character = player.Character
	local root_part = character.HumanoidRootPart

	part.Position = Vector3.new(root_part.Positon.X - 300,root_part.Positon.Y, root_part.Positon.Z)
end)

2 comments

0

well i tried that when i ran local oldCFrame = script.Parent.Player.Value.HumanoidRootPart.CFrame oldCFrame = oldCFrame + Vector3.new(300,0,0) script.Parent.CFrame = oldCFrame, but no luck

0

i just tested it but with the code slightly modfied so i could get get access to to player and part, and it worked..

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