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

This script will work in studio when I test it. But when I play in-game it doesnt. Help?

Asked by 8 years ago
01local TL = script.Parent.Parent.TL
02local TI = script.Parent.Parent.TI
03local TF = game.Players.LocalPlayer.stats.TotalFollowers
04local ClickValue = script.CV
05 
06TL.MouseButton1Up:connect(function()
07    TF.Value = TF.Value + ClickValue.Value
08    x = math.random(400)
09    TI.Visible = true
10    TI.Position = UDim2.new(0,x,0,0)
11    TI:TweenPosition(UDim2.new(0,x,1,0, "Out", "Quad", 5))
12    print("Clicked!")
13end)

This is a LocalScript inside a ImageButton

0
any errors in Output? if not, trying adding more Prints RobloxianDestory 262 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Hey, I also had this problem happening to me so many times and this problem is a common problem for scripters who use LocalScript!

According to this site, It stats that LocalScriptare the script which will begin downloading the Client's world and begin to run before any other objects have been downloaded!

My advice is that at the beginning of every LocalScript you should add wait() command. If you do not understand what I mean then let me show you an example using your script:

01wait(0.1) -- you can set it to how much time it should wait, I normally type in 0.1.
02 
03local TL = script.Parent.Parent.TL
04local TI = script.Parent.Parent.TI
05local TF = game.Players.LocalPlayer.stats.TotalFollowers
06local ClickValue = script.CV
07 
08TL.MouseButton1Up:connect(function()
09    TF.Value = TF.Value + ClickValue.Value
10    x = math.random(400)
11    TI.Visible = true
12    TI.Position = UDim2.new(0,x,0,0)
13    TI:TweenPosition(UDim2.new(0,x,1,0, "Out", "Quad", 5))
14    print("Clicked!")
15end)

Other than that everyone looks fine for me.

I hope this answer helps you. If you need any more question, feel free to ask me and I will be happy to help you in any way. :)

Ad

Answer this question