When i play it in studio the game runs fine but in a game client it doesn't trigger. trigger.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
script.Parent.hi.MouseButton1Down:connect(function() script.Parent.hi:TweenPosition(UDim2.new(-1,0,0.23,0),.6) wait(.1) script.Parent.shop:TweenPosition(UDim2.new(-1,0,0.3,0),.6) wait(.1) script.Parent.Change_log:TweenPosition(UDim2.new(-1,0,0.37,0),.6) wait(.7) script.Parent.Parent.Starta.Visible = false script.Parent.Parent.test.Visible = true script.Parent.Parent.test.Line:TweenPosition(UDim2.new(0,0,0.02,0),.3) wait(.3) script.Parent.Parent.test.Line:TweenSize(UDim2.new(0.3,0,0.009,0),.3) wait(1) script.Parent.Parent.test.shop:TweenPosition(UDim2.new(0.02,0,0.04,0),2) wait(.7) script.Parent.Parent.test.selecta:TweenPosition(UDim2.new(0,0,0,0),2) wait(1) script.Parent.Parent.test.selecta.stats:TweenPosition(UDim2.new(0.66,0,0.15,0),2) script.Parent.Parent.test.selecta.photo:TweenPosition(UDim2.new(0.3,0,0.15,0),2) wait(1) script.Parent.Parent.test.selecta.photo:TweenSize(UDim2.new(0.35,0,0.45,0),2) wait(.2) script.Parent.Parent.test.selecta.stats:TweenSize(UDim2.new(0.1,0,0.45,0),2) wait(.2) script.Parent.Parent.test.Tray:TweenPosition(UDim2.new(0,0,0,0),2) wait(1) script.Parent.Parent.test.Photos.Visible=true script.Parent.Parent.test.selecta.Car_Logo_Name.Visible=true script.Parent.Parent.test.selecta.Car_Logo_Control.Visible=true script.Parent.Parent.test.selecta.Car_Logo_Speed.Visible=true end)
If I had to guess, the problem may be line 1, and possibly the rest of the code; what /may/ be occurring is that the object hi
might not have loaded at the time of execution, but even so, there's more than that: allow me to point these problems out:
I already pointed out that the object might not have loaded at the time of execution of the script.
Unnecessary rewriting of script.Parent
s & what goes follows them; I recommend using a Variable to prevent this (Retyping of the same thing(s). (More on this later, or click the highlight word for more information)
There's so much clutter it's difficult to tell what what's going on. (What I mean by cluttered is that your code is, well, cluttered together, but also no tabbing and no spacing between code/ lines) (This may be nitpicking, but I thought to point this out anyways)
And that's essentially all the things I noticed. Now, lets begin. >>:P
DISCLAIMER: \73\32\119\105\108\108\32\110\111\116\32\98\101\32\114\101\119\114\105\116\105\110\103\32\121\111\117\114\32\115\99\114\105\112\116\59\32\73\32\97\109\32\103\111\105\110\103\32\115\104\111\119\105\110\103\32\99\111\100\101\32\116\104\97\116\32\99\97\110\47\32\119\111\117\108\100\32\98\101\32\117\115\101\100\32\97\115\32\97\32\114\101\102\101\114\101\110\99\101\46\32\73\116\39\115\32\121\111\117\114\32\106\111\98\32\116\111\32\115\101\116\32\117\112\32\121\111\117\114\32\99\111\100\101\44\32\110\111\116\32\111\117\114\115\46 (Try and decipher this; I dare you ;P )
First thing I would like to start off with is Variables; with variables, they are able to define specific objects/ value, and prevent re-typing of the same code over-and-over again (as I had said before.)
local ImAVariable = "Yay! :D" -- #1 print(ImAVariable) -- #2
For the variable (#1), it has defined "Yay! :D"
, and so, when we fire the Print (#2) function, it'll print what the variable had defined. (More on the print function later)
Now, secondly I would like to point out the most vital & important asset of any script who's set to configure with objects, the legendary problem: the object didn't load in time for the codes' execution. This can cause problems, and even break your script/ cancel all execution. To prevent/ fight this, you can use the WaitForChild function. (I'll explain what it does later on)
local RandomPart = Instance.new('Part') -- #1 spawn(function() -- #2 game.Workspace:WaitForChild('Part') -- #3 print("Part loaded! :D") end wait(2) RandomPart.Parent = game.Workspace
Just like with the last example/ explanation, the variable is defined to an object. (rather than in the first example, which was a string) As for the Spawn function (#2), (a form of Coroutine), it sets a separate thread from the rest of the code. (Not completely, it just has it so other code can pass through.) Now, finally, for the WaitForChild function (#3), it yields the code until the destined object with the same name as the argument given to it loads into the specified Parent.
Finally, to finish off, lets work on spacing out & tabbing code: it makes your code look more readable, more professional, and makes it easier to Debug it. Lets have an example of cluttered code:
function junk() game.Workspace.Part.Name = 'Pork' wait(1) game.Workspace.Pork.Name = 'Beef' wait(1) game.Workspace.Beef.Name = 'Chicken' wait(1) game.Workspace.Chicken.Name = 'Part' wait(1) end junk() junk() junk() junk()
Makes it harder to read & what's going on, right? It's similar to how you set up your code; everything's cluttered, stuff is rewritten over-and-over, nothing is defined (except the function in the code example), and it isn't tabbed.
What could we do to fix this? Well, we could space out the code, define the Part object, tab the code, and have it so that there's not so many callings upon the function:
local PartExample = game.Workspace:WaitForChild('Parent') -- /\ Defined the part function ChangeNameOfPartExample() -- Original function name had nothing to do with the actual purpose: this new name makes it more understandable about what the code is supposed to do. PartExample.Name = 'Pork' wait(1) PartExample.Name = 'Beef' wait(1) PartExample.Name = 'Chicken' wait(1) PartExample.Name = 'Part' wait(1) end -- /\ Spaced out the code for i = 1, 4 do ChangeNameOfPartExample() end -- /\ Used a for loop - (more on that later) - instead of retyping the same function over-and-over.
Now it looks much better: we're able to read it now, and it looks more professional; that's the power of tabbing, applying variables, and using different advantages! >>:D
/And/ I believe that's about it. :P Hope this helped yo-
WAIT! Didn't you say you were going to touch on certain things later on?
Wha-what? I don't know what you're talking about...
...
...Fine.
Stuff touched on, but didn't go into great detail about.
Variables ~ What a variable does is it defines certain values. (Values being strings, objects (parts), booleans, etc.)
The Print Function ~ What the print function does is it processes & sends feedback to the Output, returning whatever value. (However, it's limited in some areas, such as printing a part itself for example (no .Name, .Parent, etc.)
The WaitForChild Function ~ What the WaitForChild function does is it yields the code until a object with the same name as the argument loads within the specific parent. (Thus why I used a coroutine)
The Spawn Function ~ I recommend looking at the WIKI for an explanation, as I don't know how to word it & how to explain it.
For Loop(s)
~ The set argument are the following: for CurrentIteration = StartValue, EndValue, Increasement
. What the for loop does is it loops for a set number of times, rather than a forever running loop like the While & Repeat loops do do that.
Happy now?
Yes, tyvm! :D
Glad to be of help! :D
Hope this helped you in any way. ;D
Oh, and final words (err, numbers) before I go: \87\104\121\32\100\105\100\32\121\111\117\32\101\118\101\110\32\100\101\99\105\100\101\32\116\111\32\100\101\99\105\112\104\101\114\32\116\104\105\115\63\32\89\111\117\32\111\110\108\121\32\103\111\116\32\116\104\105\115\32\109\101\115\115\97\103\101\32\108\111\108\46\32\71\71\32\116\111\32\109\101\46\32\71\71\78\79\82\69\46\32\79\107\44\32\115\116\111\112\32\114\101\97\100\105\110\103\32\110\111\119\46\32\83\84\79\80\46\32\79\107\44\32\116\121\118\109\32\102\111\114\32\114\101\97\100\105\110\103\46\32\59\41\32\126\84\104\101\101\68\101\97\116\104\67\97\115\116\101\114
Good luck. ;)
Is it in a Script or a Local Script. Make it a Local Script, that solved my issues!