Summoning system not working

He prints the fireclient, it’s okay, but i don’t know why it isn’t working

Wait where do i put pront clicked

When you click the summon button, specifically, on the start of the function

1 Like

It showed which button it clicked
But it still doesnt work when i click the crates

Oh right, it doesn’t work when you click the summon button when you select a crate

1 Like

Found your fire client.

At the top here add tostring

mainEvent.OnClientEvent:Connect(function(eventType: string, argument1)
	if eventType == "Summon" then
		local summonedUnit = argument1
		local summonedTextLabel = mainGui.SummonTextButton.SummonFrame.CratesFrame.Summoned
		
		summonedTextLabel.Text = "You have summoned: "..summonedUnit
		mainGui.SummonTextButton.SummonFrame.CratesFrame.CoinsTextLabel.Text = "Coins: "..player.leaderstats.Coins.Value
	end
end)

Sometimes you have to do the tostring trick. The problem is, you aren’t even passing the variable truthfully. if eventType == “Summon” then is false, because it is returning an instance I believe not a string. It might have been a string going to the server but I can’t exactly remember how it works, just explained to me in various YT videos of this issue.

mainEvent.OnClientEvent:Connect(function(eventTypeIns: string, argument1)
local eventType = tostring(eventTypeIns)
if eventType == "Summon" then

One way of printing statements is to print the logic

if eventType == "Summon" then
print("True!")
end

Yea i dont know why. I think the local script is the problem.

Ok im going to see if that works

My computer died so im waiting to see if it works so sorry taking long to tell you if worked.

All good TBH it takes more testing than that to see what is happening. Always print your variables, they could even be returning nul, or completely wrong from the server. Just do print(eventType) and print(argument1).

1 Like

I hate to be that guy but you should improve your scripts… Like a lot. For example, why do you get async without a pcall (2nd one). Also, because you’re saving player data into a table when they leave without properly saving you’re causing a data leak

Oh ok so how would i make it better because im not super experienced with datastores but i knkw enough.

to

local data = nil
local tries = 5

local success, errormessage = pcall(function()
	data = coreDataStore:GetAsync(key)
		
	while tries > 0 and not data do
		data = coreDataStore:GetAsync(key)
		
		tries -= 1
		task.wait(1)
	end
end)

if not success or not data then --[[Custom handling here or you can kick the player]] end

if data then
	coins.Value = data[1]
	for i,v in pairs(data) do
		if i > 1 then
			local ownedUnit = Instance.new("BoolValue", ownedUnits)
			ownedUnit.Name = v
			ownedUnit.Value = true
		end
	end
end

Hey so it didnt work and i think i did everything you said.

mainEvent.OnClientEvent:Connect(function(eventTypeIns: string, argument1)
	local eventType = tostring(eventTypeIns)
	if eventType == "Summon" then
		print("True!")
		
		local summonedUnit = argument1
		local summonedTextLabel = mainGui.SummonTextButton.SummonFrame.CratesFrame.Summoned

		summonedTextLabel.Text = "You have summoned: "..summonedUnit
		mainGui.SummonTextButton.SummonFrame.CratesFrame.CoinsTextLabel.Text = "Coins: "..player.leaderstats.Coins.Value
	end
end)