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

This script works in Roblox Studio but not in the actual game?

Asked by 9 years ago

So this script for some reason doesn't work inside the actual game, but if I test it in Roblox Studio it works?

01local ShopButton = script.Parent
02local Shop = script.Parent.Parent.Frame
03local Close = script.Parent.Parent.Frame.X
04local GunGUI1 = Shop.Gun1
05local GunGUI2 = Shop.Gun2
06local Gun1 = game.ServerStorage:FindFirstChild("Gun1")
07local Gun2 = game.ServerStorage:FindFirstChild("Gun2")
08Player = game.Players.LocalPlayer
09 
10ShopButton.MouseButton1Down:connect(function()
11    ShopButton.Visible = false
12    Shop.Visible = true
13    Close.MouseButton1Down:connect(function()
14        ShopButton.Visible = true
15        Shop.Visible = false
View all 47 lines...
0
Is it a local script Shawnyg 4330 — 9y
0
No it's not. RetroThieff 5 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

If its a local script I would say its correct, theres no problem. If its a normal script then theres a problem at line 8. The variable have : LocalPlayer which means it needs localscript or local before the variable name. Like this for line 8 :

1local Player = game.Players.LocalPlayer

its because the normal script doesn't know what is LocalPlayer so we need to put local behind the variable. This code is for the one that doesn't use local script.

For line number 10 untill 17 I recomend you using 'if' and 'else' than making 2 functions. 1 function and if and else is okay.

0
So, if you want to do anything to players like doing game.Players.LocalPlayer, make sure you use local script or put a local on the variable of game.Players.LocalPlayer. krisxxxz 45 — 9y
Ad

Answer this question