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

Is it possible to clone an object to be placed infront of the torso?

`

local Part = game.Workspace.Test

local DropperPart = player.Charecter:WaitForChild('Torso')

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input)

if input.UserInputType == Enum.UserInputType.Keyboard then -- Checks if the input was related to a keyboard

if input.KeyCode == Enum.KeyCode.Q then

if player.Charecter then

local torso = player.Charecter:WaitForChild('Torso')

local NewPart = Part:Clone()

NewPart.Parent = torso

NewPart.CFrame = torso.CFrame

game:GetService('Debris'):AddItem(NewPart,3)

end

end

end

end)`

Heres my code I am trying to figure out what is wrong with it

1 comment

0

Wow a lot of this is messed up, you spelled a lot of this wrong.

1 answer

✓ Accepted answer

Yes it is possible. If you create two parts, one named a and another b, and run this code in command bar, workspace.b.CFrame = workspace.a.CFrame + workspace.a.CFrame.LookVector * 10, it will work.

To fix your code, to not only do this but actually work because I've spotted multiple errors in it, here you go.

local Part = game.Workspace.Test
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.Keyboard then -- Checks if the input was related to a keyboard
	    if input.KeyCode == Enum.KeyCode.Q then
		    if Players.LocalPlayer.Character then
			    local torso = Players.LocalPlayer.Character:WaitForChild("Torso")
			    local NewPart = Part:Clone()
			    NewPart.Parent = torso
			    NewPart.CFrame = torso.CFrame + torso.CFrame.LookVector * 10 --10 is the distance, in studs NewPart will be away from torso
			    game:GetService("Debris"):AddItem(NewPart,3)
		    end
	    end
    end
end)

Hopefully this works.

1 comment

0

its not spawning the blocks at all.

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