Ad
Log in to vote
1

Why Isn't my GUI not spawning parts below the player?

Asked by 6 months ago

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)

0
Hey I'm not sure what you mean , also please use the text-formats for posting the post. VitroxVox 879 — 6mo
0
Basically I want a GUI that spawns a part below the players feet imnotaguest1121 89 — 6mo

1 answer

Log in to vote
0
Answered by 6 months ago

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

Ad

Answer this question