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)
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!