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

How to solve "attempted to call field "Value" (a number value)" error?

Asked by 10 years ago

This script is supposed to display the score on a practical test out of 8, it does the theory score fine but throws an error when doing the Practical Result. I've made sure that PracticalResult does have a value inside game.Players.Local player and yet I get the error: attempted to call field "Value" (a number value)

Help is much appreciated MD


function onClick() PracScore = game.Players.LocalPlayer.PracticalScore script.Parent.Parent.Visible = false script.Parent.Parent.Parent.OverallResult.Visible = true script.Parent.Parent.Parent.OverallResult.TheoryResult.Text = "You scored: "..script.Parent.Parent.Parent.Score.Value.." out of 10" script.Parent.Parent.Parent.OverallResult.PracticalResult.Text = "You scored: "..PracScore.Value " out of 8" -- error occurs here end script.Parent.MouseButton1Click:connect(onClick)

1 answer

Log in to vote
2
Answered by
RedCombee 585 Moderation Voter
10 years ago

When you insert a value into a string, you need the periods on both sides.

Line 6:

script.Parent.Parent.Parent.OverallResult.PracticalResult.Text = "You scored: "..PracScore.Value.." out of 8"
0
Better? RedCombee 585 — 10y
0
The cause of this syntax error being "calling" is because the parenthesis are optional around function arguments if the args are literal tables or strings. For example, `print "hi"` works without parenthesis. In this case, you have `PracScrore.Value "out of 8"` which syntactically is the same as the previous snippet--hence, calling a number (.Value). BlueTaslem 18071 — 10y
0
Aha, thanks :) MasterDaniel 320 — 10y
Ad

Answer this question