[SOLVED]My script Doesnt work, even though I have no Errors, and everything is as it should be

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want to make this script print Foundation Estabilishment when conditions are fullfiled

  2. What is the issue?
    Script wont print Foundation Estabilishment Even though All conditions are fullfiled

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Everytihng, and I couldnt find any solution


local BreakthroughEvent = game.ReplicatedStorage.Breakthrough


function Breakthrough(player)
	local ServerSS = game:GetService("ServerScriptService")
	local dataManager = require(ServerSS:WaitForChild("Modules"):WaitForChild("DataManager"))
	local profile = dataManager.Profiles[player]
	
	
	if not profile then return end
	local RealmsTable = profile.Data.Realms
	
	local RealmDict = {}
	for index, realm in pairs(RealmsTable) do
		realm.Index = index
		RealmDict[realm.Name] = realm
	end
	
	local RealmsLeaderstats = game.ServerScriptService.Modules.DataManager:WaitForChild("leaderboard")
	local Qi = profile.Data.Qi
	local MortalRealm = RealmDict.Mortal
	local BodyTempering = RealmDict.BodyTempering
	local FoundationEstabilishment = RealmDict.FoundationEstabilishment
	
	if Qi >= BodyTempering.ReqQi and Qi <= BodyTempering.MaxQi and MortalRealm == RealmsTable[1] then
		local BodyTemperingRealm = RealmsTable[2]
		print(BodyTemperingRealm.Name)
		if Qi >= FoundationEstabilishment.ReqQi and BodyTemperingRealm == RealmsTable[2] then
			local FoundationEstabilishmentRealm = RealmsTable[3]
			print(FoundationEstabilishmentRealm.Name)
		end
	end
end	
	

BreakthroughEvent.OnServerEvent:Connect(function(player)
	Breakthrough(player)
end)

If necessarry I can provide other Scripts
P.S I am totally new to scripting, so I apologize for any mistakes that are obvious

Placing print()s throughout your code at different parts can help diagnose problems, especially if there is no error.

I see you have printed some values, but I also recommend printing some other variables as well after declaring them.

Adding a print to that for loop might also be really helpful

(Sorry, I’m on mobile right now and it’s kind of hard to look over code)

Solution:

I had wrong placements of Paragraphs, in meaning, I moved Foundation Estabilishment Part above
Body Tempering Part and now it works…

1 Like

It’s hard for me to help right now. If no one fixes your problem by the time I get back to my computer, I’ll try to help :+1:

maybe changing the table to that?

local template = {
	Qi = 0,
	SpiritStones = 0,
	Realms = {
		Mortal = {
			ReqQi = 0, 
			MaxQi = 99.99
		},
		BodyTempering = {
			ReqQi = 100, 
			MaxQi = 199.99
		},
		FoundationEstabilishment = {
			ReqQi = 200, 
			MaxQi = 299.99
		}
	}
}

return template

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.