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

attempt to multiply a vector3 with an incompatible value type or nil?

Asked by 5 years ago

So... i wanted to build an slide that shots u to typed in textbox value..

while true do

script.Parent.Velocity = script.Parent.CFrame.lookVector* game.StarterGui.Admin.TextBox.Text

wait()

end

and it ended with error.. "attempt to multiply a vector3 with an incompatible value type or nil."

sorry if the question is not properly.. but im new to roblox lua and kinda want to do this on start.

0
The issue is that the text of a textbox is a string, not a number. Lua has a nice function "tonumber" that allows you to convert a string to a number, if the string can be converted. If it cannot be converted, then tonumber will return nil. User#26971 0 — 5y
0
For example, tonumber("3") will return 3, and tonumber("hello") will return nil. Also, I see that you're using an infinite loop. Is that really necessary? Why not have this run on an event, such as when the text is changed or when an enter button is pressed? User#26971 0 — 5y
0
Also a screenshot of the Parent of this script would be useful and all the children of that parent. It would help for a more detailed understanding of what you are going to do. Alphexus 498 — 5y

Answer this question