How to script a button

Question, I am needing a script for a button, when it clicks it clones from SS to a players backpack. What I think so far:

local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:connect(function()
	if script.Parent.Selected==false then
if game.ReplicatedStorage.ServingSystemStorage.EC then
			local Tool = game.ReplicatedStorage.ServingSystemStorage.EC:clone()
Tool.Parent=Player.Backpack
script.Parent.Selected=true
script.Parent.Text = "Gave!"			
			wait(1)			
			script.Parent.Parent.Parent.Parent.Parent.screen.Visible = false
end
end
end)

Is this right? :smiley: I hope it is. Lol.

Few tips:

  • Please give you’re post an accurate name.

  • Please format your code.

  • Please test your code & then tell us if it works, we can’t exactly tells you if it’s working or not, we’re here to help when you get an error with your code.

Okay! It does work, but when I open the tool, the part shows up in the middle of the map.

Do you understand how tools work?

Yes. I already have the model, and it works when I use the :give command.

Alright, so when you create tools, you need to make sure that they are unanchored and that it’s welded correctly, try un-anchoring your tools.

Sorry for the slow response.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.