Okay, so I recently started learning remote events and all, and I'm still quite new to them, but anyway, in my script, whenever I try to access the level of my character, it always thinks it's 0.
Server Script:
local repStorage = game:GetService("ReplicatedStorage") local remoteEvent = repStorage:WaitForChild("LimitBreaker") local multiplier = 2 local requirement = 1 remoteEvent.OnServerEvent:connect(function(player,enabled) local localScript = game.Workspace[player.Name]:WaitForChild("Skills"):WaitForChild("LocalLimitBreaker") local aura = localScript:WaitForChild("Aura") local level = player.leaderstats.Level local char = game.Workspace[player.Name] repeat wait() until level.Value ~= 0 if enabled == false and level.Value >= requirement then -- The level variable doesn't change when the value does, and it thinks the level is 0, so this if statement never occurs. for i,v in pairs(char:GetChildren()) do if v.Name ~= "Humanoid" then for i,z in pairs(aura:GetChildren()) do z:Clone().Parent = v end end end local stats = player.Stats strength = stats:WaitForChild("Strength").StrengthLevel speed = stats:WaitForChild("Agility").AgilityLevel jump = stats:WaitForChild("Jump").JumpLevel strength.Value = strength.Value * multiplier speed.Value = speed.Value * multiplier jump.Value = jump.Value * multiplier elseif enabled == true and player.leaderstats.Level.Value >= requirement then for i,v in pairs(char:GetChildren()) do if v.Name ~= "Humanoid" then for i,z in pairs(v:GetChildren()) do if z.Name == "ParticleEmitter" then z:Destroy() end end end end strength.Value = strength.Value / multiplier speed.Value = speed.Value / multiplier jump.Value = jump.Value / multiplier end end)
Client Script:
local repStorage = game:GetService("ReplicatedStorage") local remoteEvent = repStorage:WaitForChild("LimitBreaker") local UIS = game:GetService("UserInputService") local enableKey = Enum.KeyCode.Q local enabled = false local db = false local player = game.Players.LocalPlayer UIS.InputBegan:connect(function(input) if input.KeyCode == enableKey then print("Key Pressed.") if enabled == false and db == false then db = true print("Enabled is false.") remoteEvent:FireServer(false) wait(1) enabled = true db = false elseif enabled == true and db == false then db = true print("Enabled is true.") remoteEvent:FireServer(true) wait(1) enabled = false db = false end end end)
My level right when the game loads up is indeed 0, but it then changes to 1 and it doesn't update it in the script. Does anyone know an alternate way I can do it to where it actually works? Because I need this to have a certain level requirement for my game.
Note: It probably does the same with the strength, speed, and jump variables and puts them in as what they are right when starting.