Good day developer
What do you want to achieve?
live weather readback to ui
What is the issue?
i tried for a hour always same result
ServerScriptService’s server scipt
local httpService = game:GetService("HttpService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local weather = ReplicatedStorage:WaitForChild("weather")
local weatherv = ReplicatedStorage:WaitForChild("weatherv")
local requestOptions = {
Url = "http://api.openweathermap.org/data/2.5/weather?id=" ..
"" .. --city deleted
"&apikey=" ..
""; --deleted api key
Method = "GET";
}
local function kelvinsToFahrenheit(temp)
return math.floor(((temp * 9/5 - 459.67) - 32) * 5/9)
end
local function windkots(speed)
return math.floor(speed * 1.944)
end
local function windd(deg)
return math.floor(deg)
end
local windknots = windkots(tonumber(responseBodyTable.wind.speed))
local winddeg = windd(tonumber(responseBodyTable.wind.deg))
local temperature = kelvinsToFahrenheit(tonumber(responseBodyTable.main.temp))
weatherv.OnServerEvent:Connect(function(Players, Value)
if Value == 1 then
weather:FireClient(windknots, winddeg, temperature)
end
end)
StarterGui’s localscript
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local weather = ReplicatedStorage:WaitForChild("weather")
local weatherv = ReplicatedStorage:WaitForChild("weatherv")
script.Parent.Parent.Parent.Choose.Value.Changed:Connect(function()
if script.Parent.Parent.Parent.Choose.Value.Value == 1 then
weatherv:FireServer(value)
end
if script.Parent.Parent.Parent.Choose.Value.Value == 2 then
weatherv:FireServer(value)
end
end)
weather.OnClientEvent:Connect(function(Players, windknows, winddeg, temperature)
print(windknots, winddeg, temperature)
end)
also add in server scirpt
print("Wind speed:", tostring(windknots) .. "kts")
print("Wind direction:", tostring(winddeg) .. "degrees")
print("Temperature:", tostring(temperature) .. "°C")
successful readback
so i think the problem on
weatherv.OnServerEvent:Connect(function(Players, Value)
if Value == 1 then
weather:FireClient(windknots, winddeg, temperature)
end
end)
thank for your patience to read