Im making a GUI where If you press It a part will spawn below you but In this situation I want to make a GUI that spawns a part on the tool your holding (The tool I want the part spawn Is a sword name "Part" but It appears to not be working, this Is the code:
local Button = script.Parent
Button.MouseButton1Down:Connect(function(activate) local Part = Instance.new("Part") Part.Size = Vector3.new(2.33, 2.788, 2.519) Part.Position = Vector3.new(game.Workspace.Starterpack.part) Part.Parent = workspace Part.Anchored = true Part.BrickColor = BrickColor.new("Black") end)
Please use the lua code block formats. This should work:
Button = script.Parent Button.MouseButton1Down:Connect(function() local Player = Button.Parent.Parent.Parent.Parent local Character = Player.Character local Part = Instance.new("Part") Part.Size = Vector3.new(2.33, 2.788, 2.519) Part.Position = Vector3.new(Character:FindFirstChildOfClass("Tool").Handle.Position - Vector3.new(0, 4, 0)) Part.Parent = workspace Part.Anchored = true Part.BrickColor = BrickColor.new("Black") end)
I'm also assuming this is a serverscript, and the button is located inside of a frame which is inside of a ScreenGui. If it doesn't work, add me on Discord: Undaub#4107