Button that gives weapons

  1. What do you want to achieve? Make a working button that gives weapons to the user who presses it.

  2. What is the issue? I have errors in my code which I don’t know how to fix

  3. What solutions have you tried so far? I have tried Youtube and the DevForum
    My script so far:
    local p = game.Players.LocalPlayer

script.Parent.MouseButton1Up:Connect(function()

local tool = script.Parent.Bow:Clone()

tool.parent = p.Backpack

script.Parent.Visible = false

end)
The only problem is that I cant move the weapon from wherever to the players backpack. Please help ASAP Thank you if you read this or helped me solve this.

1 Like

Can you show us your layout/hierarchy?

1 Like

What do you mean? I am new to coding and have only 1 - 2 weeks of experience.

The explorer, looks like this
image

You want me to show you my explorer?

Yes, I want to see the explorer for the button.

It would be easier for me to explain if you showed it.

The error is also there at the bottom.

First of all, since its a local script, the tool wont be visible from the server, which means the tool might have problems when used, you’ll need to tell the server to give the player the tool using remoteEvents.

1 Like

Add a remoteEvent in replicated storage

From the output, I can see you forgot the Capital P in ‘Parent’, those properties are case-sensitive, don’t forget

3 Likes

I will be back later because I have to go now. Please leave solution below and I will tell you if it worked thank you all.

You’re using a LocalScript, which Is a client side and no one will see this tool. You should add a RemoteEvent and use :FireServer() In a LocalScript and .OnServerEvent() In a Script to make It server side

For example:

LocalScript:

script.Parent.MouseButton1Down:Connect(function()
script.Parent.RemoteEvent:FireServer()
end)

Script:

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
script.Parent.Bow:Clone().Parent = plr.Backpack
--your code here
end)

Oh, and the error In the output Is because P Is not capital, It’s Parent, not parent, be careful with that. :slightly_smiling_face:

1 Like

Thank you @oli646464 for helping me it was just the Capital P and no capital P sometimes I forget that.

Ill check that out thanks for the tip.

1 Like