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

Hello! I wanted to know why my script works in studio when i test it, but doesn't in game.

Asked by 11 years ago

Its very weird, I have tried to fix it with some problems it might have caused it in the scripts... If you need the scripts, here they are:

01script.Parent.MouseButton1Down:connect(function()
02 
03        plr = game.Players.LocalPlayer
04if script.Parent.Parent.Parent.Parent.Parent.Primary.Value == "Gun" then
05for i, v in pairs (plr.Backpack:GetChildren())do
06        if v:IsA("Tool") and v.Primary.Value == true and v.Primary ~= nil and v.Name == "Gun" then
07                                 v:Destroy()
08print("Destroyed")
09elseif v:IsA("Tool") and v.Primary.Value == true and v.Primary ~= nil and v.Name == "Gun" and v.Parent == game.Players.LocalPlayer.Character then
10     v:Destroy()
11print("Destroyed from Character")
12 
13end end end
14for i, v in pairs(game.Players.LocalPlayer.PlayerGui.inventory:GetChildren()) do
15                      if not found1 then
View all 41 lines...

and second one:

01local found1 = false
02 
03script.Parent.MouseButton1Click:connect(function()
04    if game.ReplicatedStorage.Folder:FindFirstChild("Gun") then
05    c = game.ReplicatedStorage.Folder.Gun:Clone()
06    end
07    if game.ReplicatedStorage.Folder:FindFirstChild("Bow") then
08    b = game.ReplicatedStorage.Folder.Bow:Clone()
09    end
10    plr = game.Players.LocalPlayer
11if script.Parent.Parent.Parent.Parent.Parent.Primary.Value == "Gun" then
12    for i, v in pairs (game.Players.LocalPlayer.Backpack:GetChildren())do
13        if not found1 then
14    if v:IsA("Tool") then
15        if v.Primary.Value == true then
View all 51 lines...

2 answers

Log in to vote
0
Answered by
HexC3D 830 Moderation Voter
11 years ago

The answer could be that it is not a local script since it works on studios, try it and tell me.

0
alright deputychicken 226 — 11y
0
Thanks so much <3 deputychicken 226 — 11y
0
Your Welcome. :P HexC3D 830 — 11y
Ad
Log in to vote
0
Answered by
Kratos232 105
11 years ago

I don't think I could fix a problem like this without the actual model, which i'm just going to assume is a GUI. It could be that you used normal Scripts, instead of LocalScripts. Or maybe it's an actual scripting error, I don;t really know. To be honest, I just can;t be bothered reading that whole script...

Well, I hope this helped, which I doubt it did...

  • Kratos232

Answer this question