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?