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

Why wont the brick's CFrame follow me?

This script works like it's supposed to but when i move and activate the tool again it still positions itself in the same spot as it did the first time i clicked. How do i make it so that if i move and click it again it spawns at my new position?

wait(.5)
Player = game.Players.LocalPlayer
Character = Player.Character
Humanoid = Character.Humanoid
Tool = script.Parent

Tool.Activated:Connect(function()
	local brick = Instance.new("Part")
	brick.Parent = game.Workspace
	brick.Size = Vector3.new(1, 5, 5)
	brick.Anchored = true
	brick.CFrame = CFrame.new(Character.LeftFoot.CFrame, 10 , Character.LeftFoot.CFrame)
end)

3 comments

0

you have 2 CFrames inside of CFrame.new.. that's not right

0

Error messages?

0

at line 12 were your setting the CFrame do: CFrame.new(brick.Position,Character.LeftFoot.Position)

1 answer

✓ Accepted answer

Hello. I'm not sure of my answer, but I think the problem is that at lines 2 and 3, you did a variable that get the player and his character. Then, at line 12, you used those variables to spawn that part. But the lines 2 and 3 never RE-NEW, cuz you didn't put them inside a function. So the script will spawn the block every time at the same position. You can put the varibales inside the function like this:

local Tool = script.Parent

Tool.Activated:Connect(function()
	local Player = game.Players.LocalPlayer
	local Character = Player.Character
	local brick = Instance.new("Part")
	brick.Parent = game.Workspace
	brick.Size = Vector3.new(1, 5, 5)
	brick.Anchored = true
	brick.CFrame = CFrame.new(Character.LeftFoot.CFrame, 10 , Character.LeftFoot.CFrame)
end)

Also, you wrote at line 12, the CFrame of the two feet. It should be the X, Y or Z value of their positions.

local Tool = script.Parent

Tool.Activated:Connect(function()
	local Player = game.Players.LocalPlayer
	local Character = Player.Character
	local brick = Instance.new("Part")
	brick.Parent = game.Workspace
	brick.Size = Vector3.new(1, 5, 5)
	brick.Anchored = true
	brick.CFrame = CFrame.new(Character.LeftFoot.Position.X, 10, Character.LeftFoot.Position.Z)
end)

Hope this helped!

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