Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make this script work in a real game? It only works in studio testing mode.

The following code is within a LocalScript under an ImageButton in a frame within GUI. The script gives you the gun when you click the image of it and it worked just fine when I tested it in Studio, but when I played the game itself, clicking the ImageButton did nothing.

script.Parent.MouseButton1Down:connect (function()
game.ServerStorage.AK47:Clone().Parent = game.Players.LocalPlayer.Backpack
end)

Here are two videos I took.

Studio testing: https://www.youtube.com/watch?v=QxBAA_8_cNk&feature=youtu.be In-game testing: https://www.youtube.com/watch?v=ojb4jtCFE8g&feature=youtu.be

4 comments

0

put the AK47 in ReplicatedStorage and change then to game.ReplicatedStorage.AK47 ect, (local scripts can't access serverstorage)

0

Replicated Storage is accessible by Client and server (local scripts, server scripts (server scripts are just normal scripts), Server Storage is only accessible by server scripts (not local scripts)

0

and use PhotonLightnings adjustment

0

Is Fe on?

2 answers

Try this instead, i don't know if it will work. Like abnotaddable said, use ReplicatedStorage instead

local gun = game.ReplicatedStorage:WaitForChild('AK47')
script.Parent.MouseButton1Click:connect(function ()
gun:Clone().Parent=game.Players.LocalPlayer.Backpack

I think its becuase connect is depracated, use Connect instead. Plus I think, you should use MouseButton1Click becuase MouseButton1Down is used for holding the left click button.

script.Parent.MouseButton1Click:Connect(function()
game.ServerStorage.AK47:Clone().Parent = game.Players.LocalPlayer.Backpack
end)

1 comment

0

Still not working even with 1Click and the adjusted Connect

This discussion is preserved as it was. New answers, comments, and votes are closed.