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

Can anyone explain why my code works on the Studio test run, but doesn't work on the real game?

Asked by 7 years ago
Edited 7 years ago

I have a pretty big script here, and it took me forever to make it. Its 2 scripts split up by LocalScripts. I've tested it in Studio, and it works perfectly. Yet, when i play the actual game, it start making up problems. Here is the code now. Its 1 local script in StarterGui

01local UIS = game:GetService('UserInputService')
02local pressing
03local Energy = 90
04local player = game.Players.LocalPlayer
05local character = player.Character
06local PrettyColor = false
07if not player or not character.Parent then
08    character = player.CharacterAdded:wait()
09end
10local torso = character.LowerTorso
11local fire = Instance.new("Fire")
12fire.Parent = torso
13fire.Enabled = false
14fire.Heat = 6
15fire.Size = 6
View all 48 lines...
0
I used to have it in 2 scripts, and they communicated by _G. But the GameRun decided it doesnt work anymore. Said i was trying to call a nil value of a function. So, i merge the scripts together (i wish they stayed seperate) and now its saying that LowerTorso isnt a valid member of Model (line 10) User#19492 0 — 7y
0
As far as I know, the CharacterAdded:Wait() event never seems to work in-game. This is what I'd do: "repeat wait () until plr.Character and plr.Character:FindFirstChild("HumanoidRootPart")" Mayk728 855 — 7y
0
Are you sure that will work 100%? User#19492 0 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

Do you have filtering enabled turned on, if so... (I can't seem to comment - probably because of my low reputation so I can only say it here):

I've read about such situations before and have experienced it first hand and and I can likely tell you that this is as in studio, the local scripts act as normal scripts. So if you have filtering enabled, since local scripts can't communicate with the server, anything that changes the server should not work in the real game.

In your script:

1local fire = Instance.new("Fire")
2fire.Parent = torso
3fire.Enabled = false
4fire.Heat = 6
5fire.Size = 6

These things are the ones that has to be created by the server so that everyone see it, thus, it is most probably this that causes the local script to stop working. Note: Only if you have filtering enabled.

Solution: Personally, I would create a remote event to communicate with a server script to do it.

0
that isnt a problem. Seems to register that just fine. However, it is saying the character doesnt exist. User#19492 0 — 7y
Ad

Answer this question