Script doesn't give player gear

  1. What do you want to achieve?
    When an admin press the button he gains an gear.

  2. What is the issue?
    5086335b0d7bdb289ec2e2dbbcd759d0

  3. What solutions have you tried so far?
    I tried looking at devhub and tutorials.

local player = game:GetService("Players")
local minigun = game.ServerStorage:WaitForChild("Minigun")
local sound = script.Parent.Parent.Parent.Parent.UIClick
script.Parent.MouseButton1Click:Connect(function()
	sound:Play()
	if player.Name == "GuipaGG1" or "istoleyourlunchmeat" then
		local newmini = minigun:Clone()
		newmini.Parent = player.Backpack
	else
		return
	end
end)

Instead of server storage where the UI cannot access you can do ReplicatedStorage.

Try placing your minigun under game.ReplicatedStorage instead. Seems like you are using a Local Script.

After you put your minigun from game.ServerStorage to game.ReplicatedStorage, change your code to:

local player = game:GetService("Players").LocalPlayer
local minigun = game.ReplicatedStorage:WaitForChild("Minigun")
local sound = script.Parent.Parent.Parent.Parent.UIClick
script.Parent.MouseButton1Click:Connect(function()
	sound:Play()
	if player.Name == "GuipaGG1" or "istoleyourlunchmeat" then
		local newmini = minigun:Clone()
		newmini.Parent = player.Backpack
	else
		return
	end
end)

8b2d779dfb96ab218aaded56c1da0c33

Okay UI is not accessible to the Server, manually you can move it into replicated storage and fix the problem. :wink:

It still doesn’t work, there’s error0c4ec9dbf98938bca39087ce0f1a831a

How you do it would be

local minigun = game.ReplicatedStorage:WaitForChild("Minigun")

would easily fix the problem but can you show me?

The script is

local player = game:GetService("Players").LocalPlayer
local minigun = game.ReplicatedStorage:WaitForChild("Minigun")
local sound = script.Parent.Parent.Parent.Parent.UIClick
script.Parent.MouseButton1Click:Connect(function()
	sound:Play()
	if player.Name == "GuipaGG1" or "istoleyourlunchmeat" then
		local newmini = minigun:Clone()
		newmini.Parent = player.Backpack
	else
		return
	end
end)

Ah sorry, didn’t see, you can also do a backup way which is

script.Parent.

but I’d advise not too, can you do game.Players.LocalPlayer.Backpack, or did you try that already?

1 Like

Thanks it worked. )()()()()*()(

My bad, we’re typing really fast aha.

How does your final script look like? Just curious.

local player = game:GetService("Players").LocalPlayer
local minigun = game.ReplicatedStorage:WaitForChild("Minigun")
local sound = script.Parent.Parent.Parent.Parent.UIClick
local debounce = false
script.Parent.MouseButton1Click:Connect(function()
	sound:Play()
	if player.Name == "GuipaGG1" or "istoleyourlunchmeat" and debounce == false then
		local newmini = minigun:Clone()
		newmini.Parent = player.Backpack
        warn("Admin has got minigun")
      debounce = true
wait(4)
debounce = false
	else
		return
	end
end)

Okay I see, but just as a reference, the code you used was from my reply:

It’s not a problem that you gave the solution to @CoasterOof , but next time try to give props to the one that took the time to help you get the problem solved and working :stuck_out_tongue: !