The issue where is setting the number. I’m making a temperature system. I have a script that’s in serverscriptservice and modulescript is under script.
– ServerScriptService (TemperatureRemote) –
local Temp = require(script.TemperatureModule)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local playertemp = Temp.GetTemperature(player)
print(playertemp)
wait(5)
Temp.SetTemperature(player, 10)
print(Temp.GetTemperature(player))
end)
– ModuleScript (TemperatureModule) –
local Temp = {}
local function isValidPlayer(player)
return player and player:IsA("Player")
end
local function NewTemperature(player)
local char = player.Character or player.CharacterAdded:Wait()
local Temperature = Instance.new("NumberValue")
Temperature.Name = "Temperature"
Temperature.Value = 15
Temperature.Parent = char
end
function Temp.GetTemperature(player)
isValidPlayer(player)
local char = player.Character or player.CharacterAdded:Wait()
if char:FindFirstChild("Temperature") then
return char:FindFirstChild("Temperature").Value
else
NewTemperature(player)
return char:FindFirstChild("Temperature").Value
end
end
function Temp.SetTemperature(player, setNumber)
isValidPlayer(player)
local char = player.Character or player.CharacterAdded:Wait()
if char:FindFirstChild("Temperature") then
local temp = char:FindFirstChild("Temperature").Value
temp = setNumber
print(temp)
end
end
return Temp
What I’m expecting is an output print.
15 - Server - TemperatureRemote:6
10 - Server - TemperatureModule:32
10 - Server - TemperatureRemote:10
But real output printing this
15 - Server - TemperatureRemote:6
10 - Server - TemperatureModule:32
15 - Server - TemperatureRemote:10
Any suggestions will be appreciated.