"value of type Instance cannot be converted to a number" Warning, How do i fix?

Hello Devs! I Am Making A Customization Feature In My Game, But When I Try To Change The NumberValue, It Gives Me The “value of type Instance cannot be converted to a number”, And i have looked for around an hour and i could not find anything that could help me, So I am making this post.

Server Script (ServerScriptService) :

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerEvents = ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("ServerEvents")

ServerEvents.ChangeHat.OnServerEvent:Connect(function(Player: Player, HatNumber)
	local HatValue = Player:FindFirstChild("leaderstats"):WaitForChild("Hat")

	print(HatValue.Name, HatValue.ClassName)
	HatValue.Value = HatNumber
end)

Local Script (Inside A TextButton) :

repeat task.wait(0.25) until game.Loaded or game:IsLoaded()

local Player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerEvents = ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("ServerEvents")

local HatValue = 1

script.Parent.MouseButton1Click:Connect(function()
	ServerEvents.ChangeHat:FireServer(Player, HatValue)
end)

How Do I Fix This?

Hey! Could you let me know if the print statement within the first script given actually prints information about the value?

Yes It Does,

image

“HatNumber” is referring to a numberValue. This is an instance. You want its value, which you can get with HatNumber.Value

1 Like

Remove “Player” when firing changehat event from client

1 Like

Oh, that was an easy fix, Thanks!

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