Attempt to index number with 'Value'

Greetings,

The value is a NumberValue so it should have worked. Please help me with this error, I got no idea why it occurred. Thanks!

The error:
image

The code:

task.wait(3)
--Services
local players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")

--Events
local SendGUI = RS:WaitForChild("Racing"):WaitForChild("SendGUI")
local Bindable = RS:WaitForChild("Racing"):WaitForChild("Bindable")

--Items
local Racetrack1 = script.Parent
local PlayersFolder = Racetrack1.Players

local FinishLine = Racetrack1.FinishLine
local Participants = Racetrack1.Participants
local Ongoing = Racetrack1.Ongoing

local debounce = false
local place = Racetrack1.Place

FinishLine.Touched:Connect(function(hit)
	if debounce == false then
		debounce = true
		
		warn("I have received the touch")
		
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		
		if player and Ongoing.Value == true then
			warn("I've seen that the value is true")
			if players:FindFirstChild(player.Name) and PlayersFolder:FindFirstChild(player.Name) then
				warn("I have found player, so both of the things are found.")
				place.Value += 1 --The line where the error occurred

				PlayersFolder:WaitForChild(player.Name).Value = place.Value
				
				local otherserver = 2 
				Bindable:Fire(otherserver, player)
				warn("I've also fired the bindable event to the script in sss, my job is done here :D")
			end
		end
		
		wait(0.05)
		debounce = false
	end
end)

Have you ensured that you have called the value attribute of the value item?

Yes i have, as you can see the object is defined and also .Value is present when I add. I use this script for a race, and it worked before with no issues, I haven’t done any modifications to it but now I get this error.

It might sound silly, but something similar has happened to be in the past.

So…

Instead of place.Value += 1 you can place place.Value = place.Value + 1
[it’s basically the same thing but written different]

Also make sure:

  • place is called the NumberValue [the value you want to edit, so when you mention in on the script place.Value you call Value the Data Value]
1 Like

Alright, it works I guess, I mean I don’t know when it doesn’t, as I said, it worked the first time but then it crashed (probably because 2 people did it at the same time). Since it’s a race I can’t prevent those, so I moved the adding stuff to a different script so that the touch function doesn’t get overwhelmed. Thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.