Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago
Edited 7 years ago

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

0
put the AK47 in ReplicatedStorage and change then to game.ReplicatedStorage.AK47 ect, (local scripts can't access serverstorage) abnotaddable 920 — 7y
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) abnotaddable 920 — 7y
0
and use PhotonLightnings adjustment abnotaddable 920 — 7y
0
Is Fe on? iamnoamesa 674 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

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
Ad
Log in to vote
0
Answered by
phxtn 154
7 years ago
Edited 7 years ago

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)
0
Still not working even with 1Click and the adjusted Connect TurtlesMelons 0 — 7y

Answer this question