So, I am trying to make a textbox if where you put 0.9, it will put the car's height like a lowrider. But it is not changing and gives me this error: 18:05:06.931 - Players.squidiskool.PlayerGui.ScreenGui.TextBox.Script:1: attempt to call field 'Text' (a string value)
Here is the code if you want to look further:
1 | if script.Parent.Text ( "0.9" ) then |
2 | game.Workspace.body.Position ( "5.167" ) |
3 | end |
I am a beginner in coding, so I am not perfect.
Hey, so this should work.
01 | local Box = script.Parent |
02 | Box.FocusLost:Connect( function (enterPressed) |
03 | if enterPressed then |
04 | print ( "Input recieved" ) |
05 | end |
06 | local Number = ( "0.9" ) |
07 | if Box.Text = = (Number) then |
08 | print ( "Input is equal to number" ) |
09 | --Add your stuff here |
10 | end |
11 | end ) |
Make a local script with these lines & put it inside a textbox. It will compare the input to the number you specify and perform an action if correct.
I did change the code a bit, but it still outputs the error.
1 | if script.Parent.Text ( "0.9" ) then |
2 | game.Workspace.body.Position ( "-5.408, 4.167, 21.135" ) |
3 | end |
First, use == for comparing two values if they equal.
Second, .Positions arent just one value. Imagine it's a value containing 3 other values.
This value for .Position is Vector3. Vector3 contains X, Y, and Z. To set the .Position, feed it a Vector3 value.
workspace.body.Position = Vector3.new(X, Y, Z)
X would be numbers of X coordinate, Y would be numbers of Y coordinate, and Z would be numbers of Z coordinate.
Hi, I'm not sure where you learned how to compare values like that, but here is your code but functional.
1 | if script.Parent.Text = = "0.9" then |
2 | workspace.body.Position = Vector 3. new(- 5.408 , 4.167 , 21.135 ) |
3 | end |