When I try to return a value from :FireClient, it would give the number to the server, But when it does it sees it as nil.
I tried debugging some things, Somehow the client doesn’t see the number as nil.
– Local Script
game:GetService("ReplicatedStorage").returnClientValue.OnClientEvent:Connect(function()
local gui = game.Players.LocalPlayer.PlayerGui.ScreenGui
local num = tonumber(gui:WaitForChild("count").count.Value)
warn("real"..num)
return num
end)
– ServerScript
local playerworld = game:GetService("Workspace")
local plr = game:GetService("Players")
local cubesfolder = playerworld:FindFirstChild("Cubes")
local rep = game:GetService("ReplicatedStorage")
local zab = require(game:GetService("ReplicatedStorage").Services.Zone)
local light = true
plr.PlayerAdded:Connect(function(player)
local playerValues = player:WaitForChild("savedCubes")
for _, v in pairs(cubesfolder:GetChildren()) do
if v:IsA("BasePart") then
local container = v
local zone = zab.new(container)
zone:setDetection("WholeBody")
zone:setAccuracy("Precise")
zone.playerEntered:Connect(function(plr)
if light then
rep.returnClientValue:FireClient(plr)
local boolvalue = playerValues:FindFirstChild(v.Name)
boolvalue.Value = true
warn(rep.returnClientValue:FireClient(plr))
local add = rep.returnClientValue:FireClient(plr) + 1
rep:FindFirstChild("requestDestroy"):FireClient(plr,v)
rep:FindFirstChild("updateCounter"):FindFirstChild(plr,add)
zone:destroy()
rep.sendMessage:FireAllClients(v,plr)
light = false
task.wait(0.2)
light = true
end
end)
end
end
end)