What’s wrong with this weapon giver?

I am trying to make a weapon giver and this script I wrote isn’t behaving.


game.ReplicatedStorage.WeaponsFolder.Weapons.Parent = StarterGui

local weapons = game.ReplicatedStorage.WeaponsFolder

local MouseButton1Click = weapons

when clicked do

game.ReplicatedStorage.WeaponsFolder.Weapon1.Parent = workspace

game.StarterGui.WeaponGiverGui.MouseButton1Click = game.ReplicatedStorage.WeaponsFolder.Weapon1 = workspace

end

Yeah there are quite some issues with this one

I assumed you are using a ClickDetector, and a Script

game.ReplicatedStorage.WeaponsFolder.Weapons.Parent = game.StarterGui -- make sure to include game. before

local weapons = game.ReplicatedStorage.WeaponsFolder

local clickDetector = script.Parent.ClickDetector -- path to the click detector

-- local MouseButton1Click = weapons -> not sure what this is, but MouseButton1Click is an Event so can't be used as variable name

clickDetector.MouseClick:Connect(function(plr) -- when clicked do is not a thing
   game.ReplicatedStorage.WeaponsFolder.Weapon1.Parent = game.workspace

   -- lets break this next part down
   -- game.StarterGui.WeaponGiverGui.MouseButton1Click -> MouseButton1Click is an Event, so can't be used as variable name
   --game.ReplicatedStorage.WeaponsFolder.Weapon1 = workspace -> not sure what this is supposed to do

   -- so the last bit should be (assuming this is what you want, your script is hard to understand)
   game.ReplicatedStorage.WeaponsFolder.Weapon1:Clone().Parent = game.Workspace -- replace game.Workspace with plr.Backpack if you want it to go the player's inventory
end)

Again, your script was hard to understand so might not be 100% accurate, the script will detect a click from the ClickDetector, clone the gun and give it to the player/place it in the workspace

Any doubts just ask, were here to help.

Now, you seem to have quite the trouble with scripting, I suggest learning more of the basics before jumping into something bigger.

1 Like