Value printing nil although the value is not nil

Hey there,
I have this messaging service script and webhook that updates across every server. That all works fine but in the messaging service script I have it put the message into a string value, Then in the webhook when i try and get that value it says its nil?

Webhook:

local PetWebhookModule = {}

--// Services
local HttpService = game:GetService("HttpService")

--// URL
local webhookUrl = ""


local GetWebhookColor = function(rarity)
	if rarity == "Legendary" then
		return 16766976
	elseif rarity == "Mythic" then
		return 65280
	elseif rarity == "Mystery" or rarity == "Secret" then
		return 1059548
	end
	return 16766976
end

function PetWebhookModule:SendWebhook(Player, PetName, Rarity, Chance)
	if script.WebhookOn.Value == false then return end
	--// ^^ REMOVE
	
	local DataStoreService = game:GetService("DataStoreService")
	local DataStore = DataStoreService:GetDataStore("SecStats")
	local secs = game.ReplicatedStorage.SecretsHatched
	secs.UniThing.Value = secs.UniThing.Value + 1
	local counter = game.ReplicatedStorage.Value.Value
	
	if Player ~= nil and PetName ~= nil and Rarity ~= nil and Chance ~= nil then
		spawn(function()
			print(counter)
			local color = GetWebhookColor(tostring(Rarity))
			local data = HttpService:JSONEncode({
				["embeds"] = {{
					["title"] = "Someone Hatched A ".. tostring(Rarity).." ".. tostring(PetName).." Pet (".. tostring(Chance)..")!",
					["description"] = "Player: ".. tostring(Player.Name).. " Amount Hatched: "..counter,
					["color"] = (color or 16766976),
				}}
			})
			if data ~= nil then
				HttpService:PostAsync(webhookUrl, data)
			end
		end)
	end
end

return PetWebhookModule

Publish message script:

local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")

local MESSAGING_TOPIC = "SecHatch"

local updateLabelEvent = Instance.new("RemoteEvent")
updateLabelEvent.Parent = game.ReplicatedStorage
updateLabelEvent.Name = "UpdateSecCounter"

Players.PlayerAdded:Connect(function(player)
	
	local secs = game.ReplicatedStorage:WaitForChild("SecretsHatched").UniThing

	-- Subscribe to the topic
	local subscribeSuccess, subscribeConnection = pcall(function()
		return MessagingService:SubscribeAsync(MESSAGING_TOPIC, function(message)
			updateLabelEvent:FireClient(player, message.Data)
		end)
	end)
	if subscribeSuccess then
		updateLabelEvent:FireClient(player, secs.Value)

		-- Unsubscribe from topic upon player ancestry change
		player.AncestryChanged:Connect(function()
			subscribeConnection:Disconnect()
		end)
	end

	-- Publish to topic
	secs.Changed:Connect(function()
	local publishSuccess, publishResult = pcall(function()
		local message = secs.Value
		MessagingService:PublishAsync(MESSAGING_TOPIC, message)
	end)
	if not publishSuccess then
		updateLabelEvent:FireClient(player, publishResult)
		end
	end)
end)

Recive message script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local updateLabelEvent = ReplicatedStorage:WaitForChild("UpdateSecCounter")

local function onUpdateLabel(str)
	ReplicatedStorage.Value.Value = str
	script.Parent.Text = str
end

updateLabelEvent.OnClientEvent:Connect(onUpdateLabel)

Output:
image

thats not nil thats just blank like “”

1 Like

My bad, Do you know why its not printing anything tho when it clearly has a value?

Is that print a result of the not publishsuccess?

if not publishSuccess then
		updateLabelEvent:FireClient(player, publishResult)
		end
	end)

which goes to here?:

local function onUpdateLabel(str)
	ReplicatedStorage.Value.Value = str
	script.Parent.Text = str
end

or message.Data?

1 Like

It is a Message.Data print in another script, i think

try just printing message and seeing what prints and send result to me

1 Like

My studio is being really laggy sorry, gimme a sec

Here you go, It works fine.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local updateLabelEvent = ReplicatedStorage:WaitForChild("UpdateSecCounter")

local function onUpdateLabel(str)

ReplicatedStorage.Value.Value = str

script.Parent.Text = str

print(str) -- This prints

end

updateLabelEvent.OnClientEvent:Connect(onUpdateLabel)

image

thats not the same as line 33 on petwebhook

image

im a little confused

1 Like

Yeah, so the line 33 is in my webhook and the one i just printed is in the script that gets the message