Does anyone know how to make a dropper where you click a button and then a 1 by 1 by 1 part falls beneath the dropper? I only know how to do automatic ones, I just dont know how to make it where you click to make it work.
Part with click detector, when clicked by a player it clones an item from somewhere and sets the CFrame to a defined position. At least that’s how I’d handle it.
References:
How do you get the clicked by the player part of that though?
The first parameter passed from the MouseClick
signal is the Player
who fired it.
ClickDetector.MouseClick:Connect(function(player)
print(player.Name, "clicked me!")
end)
ClickDetector.MouseClick:Connect(function()?
What part about it is confusing you? ClickDetector
is the click detector object, MouseClick
is the event that is fired when the ClickDetector is clicked, which is connected using Connect
to fire a function.
As vtae pointed out, one of the possible parameters that Roblox finds is the player who clicked on the part, which you can use.
Im making the script rn one sec.
local Button = game.Workspace[“Bunker World”].Droppers.StarterDropper1.buttonToWorkDropper
local Dropper = game.Workspace[“Bunker World”].Droppers.StarterDropper1.dropperPartOfThis
Button.ClickDetector.MouseClick:Connect(function()
local part = Instance.new(“Part”)
part.Size = Vector3.new(1,1,1)
part.Position = script.Parent.Parent.dropperPartOfThis - Vector3.new(0,2,0)
end)
It didn’t work.
You can use ```lua to make your code easier to read on the forums.
part.Position = script.Parent.Parent.dropperPartOfThis - Vector3.new(0,2,0)
I’m guessing script.Parent.Parent.dropperPartOfThis
is an object, not a Vector3 position. Since you didn’t tell me your error, I’m guessing that it’s trying to set the position, but it can’t subtract a Vector3 from an object.
local Button = game.Workspace["Bunker World"].Droppers.StarterDropper1.buttonToWorkDropper
local Dropper = game.Workspace["Bunker World"].Droppers.StarterDropper1.dropperPartOfThis
Button.ClickDetector.MouseClick:Connect(function()
print("Hi")
local part = Instance.new("Part")
print("Hello")
part.Size = Vector3.new(1,1,1)
print("Howdy")
part.Position = script.Parent.Parent.dropperPartOfThis - Vector3.new(0,2,0)
print("Hola")
end)
It didn't print Hola and the error said : 00:11:13.081 - Workspace.Bunker World.Droppers.StarterDropper1.buttonToWorkDropper.Script:9: bad argument #1 (Vector3 expected, got Object)
dropperPartOfThis.Position - Vector3.new(0,2,0)
Ohhhh Thank you so much I was dumb
local Button = game.Workspace["Bunker World"].Droppers.StarterDropper1.buttonToWorkDropper
local Dropper = game.Workspace["Bunker World"].Droppers.StarterDropper1.dropperPartOfThis
Button.ClickDetector.MouseClick:Connect(function()
print("Hi")
local part = Instance.new("Part")
print("Hello")
part.Size = Vector3.new(1,1,1)
print("Howdy")
part.Position = script.Parent.Parent.dropperPartOfThis.Position - Vector3.new(0,2,0)
print("Hola")
end)
There wasn’t an error this time but it still didn’t work
What is “dropperPartOfThis”?
30
Don’t forget to set the parent of the new part.
Just copied and pasted the script, added
part.Parent = Dropper
And it seemed to work.
It’s the part of the dropper that the part will come out of.
Some extra helpful info regarding positioning coordinates in roblox:
When using coordinates to move/position objects, you can only use part based objects. Like a normal part, union, MeshPart e.t.c.
There are two main types of coordinated positioning in roblox physically, this is
Vector3 and CFrame
There is not much difference between the two other than that CFrame gives a wide variety of options such as angles, toworldspace, interpolation e.t.c.
When moving and positioning parts you might recieve an error saying Vector3 value expected got CFrame
or the other way around. Some parts or methods require a CFrame or Vector3 counterpart in order to function correctly.
To summarise:
New Vector3 coordinate: Vector3.new(x,y,z)
New CFrame coordinate: CFrame.new(x,y,z)
Default Vector3 value: Part.Position
Default CFrame value: Part.CFrame
Hope this helps!
Thank you, I remade the script and added part.Parent
local Button = game.Workspace["Bunker World"].Droppers.StarterDropper1.buttonToWorkDropper
local Dropper = game.Workspace["Bunker World"].Droppers.StarterDropper1.dropperPartOfThis
local function createPart()
local part = Instance.new("Part")
part.Parent = Dropper
part.Size = Vector3.new(1,1,1)
part.Position = Dropper.Position - Vector3.new(0,2,0)
end
Button.ClickDetector.MouseClick:Connect(createPart)
This worked!