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
local TL = script.Parent.Parent.TL
local TI = script.Parent.Parent.TI
local TF = game.Players.LocalPlayer.stats.TotalFollowers
local ClickValue = script.CV

TL.MouseButton1Up:connect(function()
    TF.Value = TF.Value + ClickValue.Value
    x = math.random(400)
    TI.Visible = true
    TI.Position = UDim2.new(0,x,0,0)
    TI:TweenPosition(UDim2.new(0,x,1,0, "Out", "Quad", 5))
    print("Clicked!")
end)

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:

wait(0.1) -- you can set it to how much time it should wait, I normally type in 0.1.

local TL = script.Parent.Parent.TL
local TI = script.Parent.Parent.TI
local TF = game.Players.LocalPlayer.stats.TotalFollowers
local ClickValue = script.CV

TL.MouseButton1Up:connect(function()
    TF.Value = TF.Value + ClickValue.Value
    x = math.random(400)
    TI.Visible = true
    TI.Position = UDim2.new(0,x,0,0)
    TI:TweenPosition(UDim2.new(0,x,1,0, "Out", "Quad", 5))
    print("Clicked!")
end)

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