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

How come a part wont be put into workspace when a player dies?

Asked by 3 years ago
Edited 3 years ago

I'm trying to make a system where a gun drops when a player dies, but the gun that is in the form of a part for testing is not being cloned and put into workspace near or at the characters HumanoidRootPart Position.(the tool is going to be a mesh that looks like the tool)

local ReplicatedStorage = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAppearanceLoaded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")

        ---SecondaryTool
        local Tool = Player.Backpack:FindFirstChild("M1911A1")

        ---DropTool
        local DropTool = ReplicatedStorage:WaitForChild("DropItems"):WaitForChild("M1911Drop"):Clone()

        Humanoid.Died:Connect(function()
            if Player.Team.Name == "Division Black" then
                if Tool then
                    DropTool.Parent = game:GetService("Workspace")
                    DropTool.Position = Character:WaitForChild("HumanoidRootPart").Position
                end
            end
        end)
    end)
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Position is not a property of a tool?

Were there any other errors?

The only solution I can think of is

 DropTool.Model:SetPrimaryPartCFrame(CFrame.new(Character:WaitForChild("HumanoidRootPart").CFrame))

Just make sure you have a Primary Part set for the model and change .Model to whatever your tool's model is called.

0
I kinda misworded the "tool" isn't really like a tool its just what I call it in reality its going to be a mesh or a part. also I get no errors. Sorry for the confusion. vincentthecat1 199 — 3y
0
You can try adding prints around your code to see when it stops. DietCokeTastesGood 111 — 3y
Ad

Answer this question