Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script Error: Attempt to perform (sub) on string and number?

script.Parent.Text = "FINGER SURGERY WILL COST THIS MUCH: " - 250 * wait(2) rawget(game.Players.LocalPlayer:WaitForChild("PlayerGui").Values.NC.NCValue.Value)

The code above is supposed to make a cost of getting something multiplied by how many of the things you have. I dont know how to get it to not say the other error i used to get,

The errors before i did rawget: Attempt to index nil with WaitForChild and: Attempt to index nil with PlayerGui

The errors werent togetther but just failed attempts of the script. Yes, it is a script inside a TextButton inside a Frame inside a ScreenGui

I though using wait would wait for the screen gui to actually get into the player, because there is no playergui already inside the player before playing.

1 answer

Here, in your script, it looks like you are trying to subtract a string. script.Parent.Text = "FINGER SURGERY WILL COST THIS MUCH: " - 250 If you want to get a number, you can do this:

local cost = 250
script.Parent.Text = "FINGER SURGERY WILL COST THIS MUCH: "..cost

3 comments

0

ok now its attempting to index nil with wait fro child and the cost is 503.223425 somehow

0

now its 504.18805

0

it seems to vary in the 500's be cause i rejoined and got 502.71819999999

This discussion is preserved as it was. New answers, comments, and votes are closed.