Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

`

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

0
Wow a lot of this is messed up, you spelled a lot of this wrong. User#25281 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

0
its not spawning the blocks at all. voidofdeathfire 148 — 5y
Ad

Answer this question