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

Script working in studio, but not online Help?!

Asked by 7 years ago
Edited 7 years ago

I can't get this script to work for some reason and I use WaitForChild, but it still doesn't work, help!

EDIT: Simplified this script with an equation, still doesn't run on online play.


local movenumber2 = script.Parent local SOP = movenumber2.Parent.Parent:WaitForChild('MillisecondsOnesPlace') local HTPI = SOP:WaitForChild('ImageLabel') local Hit3 = HTPI:WaitForChild('MillisecondsOnesPlaceHitValue') local Hit4 = movenumber2:WaitForChild('MillisecondsTensPlaceHitValue') Hit3.Changed:connect(function() local val = Hit3.Value if val == 10 then movenumber2.Position = UDim2.new(0,0,0,0) Hit4.Value = Hit4.Value + 1 else movenumber2.Position = UDim2.new(0,-2.3714e-16 - 36.31507936507811*val - 5.902976190479389*val^2 + 19.965928130514644*val^3 - 15.415625000001649*val^4 + 5.712210648148644*val^5 - 1.1729166666667565*val^6 + 0.13672288359789322*val^7 - 0.00848214285714342*val^8 + 0.0002177028218695024*val^9,0,0) end end)
0
If you're handling with GUIs, this should be on the client. User#15029 30 — 7y
0
Does Hit3.Changed actually fire? You may have mispelled something and there could be an infinite WaitForChild stopping the rest of the code from running. Add a print after Hit3.Changed fires and let me know if it works. User#15029 30 — 7y
0
@Sublivion Yeah everything works as scripted in studio, but not online. JoeRaptor 72 — 7y
0
@JoeRaptor Check to see if hit3 ever changes on that specific client. You can do this by temporarily turning on and off FE. User#15029 30 — 7y

1 answer

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

Solution

.Changed will only work on a localscript when handling with objects which are on the client such as a user interface.

It is not the elseif statements that aren't working, it's that the event is never being called.

The solution, assuming that you haven't already done so, would be to put this in a localscript.

Side Note

What you're doing now is quite inefficient.

You could do something similar to

movenumber2.Position = UDim2.new(0, val * -30, 0, 0)
0
But it is in a localscript... @Sublivion JoeRaptor 72 — 7y
0
@Sublivion I would use something like that but I can't find an equation that would get my desired result. JoeRaptor 72 — 7y
0
@JoeRaptor I see, I will write another answer. As for that, I agree with you there and can't find an exact correlation between val and that number exactly other than a rough estimate. User#15029 30 — 7y
0
@Sublivion I made an edit on my script based on what I'm about to say now. So I found a guy that could make a function based on the sequence of numbers above, but I still can't make the script work online. So why the script doesn't work, is still the question. JoeRaptor 72 — 7y
Ad

Answer this question