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

Trying to spawn part at player on tool click, no errors? [SOLVED]

Asked by 4 years ago
Edited by DeceptiveCaster 4 years ago

There aren't any errors as I said, so I can't figure out what's wrong.. I am a complete noob when it comes to scripting so... If you answer my question pls explain the logic behind your answer, helps a ton.

--// Vars \\--
local User = game.Players.LocalPlayer
local Char = User:WaitForChild("Character")
local humanoidrootpart = Char.HumanoidRootPart

--// Settings \\--
local newpart = Instance.new("Part",workspace)
local position = Char.HumanoidRootPart.CFrame

--// Part Spawn \\--

script.Parent.Equipped:Connect(function(Mouse)
    Mouse.Button1Down:Connect(function()
newpart.BrickColor = BrickColor.new("Burnt Sienna")
newpart.Material = Enum.Material.Neon
newpart.Anchored = true
newpart.CFrame = position
newpart.Parent = game.Workspace
    end)
end)    

1 answer

Log in to vote
0
Answered by 4 years ago

I found that the problem lied in how I was trying to get to the character, the char didn't actually exist yet so I had to use :CharacterAdded, Ankur_007 helped out by answering another post of mine.

Ad

Answer this question