You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want the GUI to only show up once -
What is the issue? Include screenshots / videos if possible!
My Problem is that the remote event in the CheckExp function can be fired multiple times although theres a variable called gotLevel2 that should not allow this im really dumbfounded here and tried tooooo many things i hope you can help me
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local RepStorage = game:GetService("ReplicatedStorage")
local Fish = require(RepStorage.Fish)
local FishAbilitys = require(RepStorage.FishAbilitys)
local gotLevel2 = false
local gotLevel3 = false
local gotLevel4 = false
local gotLevel5 = false
RepStorage.Evolution.Evolution1Remote.OnServerEvent:Connect(function(plr)
local leaderstats = plr:FindFirstChild("leaderstats")
local XP = leaderstats:FindFirstChild("XP")
local Stamina = leaderstats:FindFirstChild("Stamina")
if XP.Value >= 100 and gotLevel2 == true then
local oldchar = game:GetService("StarterPlayer"):FindFirstChild("StarterCharacter")
if oldchar then
oldchar:Destroy()
end
local newchar = Fish.Level_2.Jellyfish.Model:Clone()
newchar.Name = "StarterCharacter"
newchar.Parent = game:GetService("StarterPlayer")
plr:LoadCharacter(newchar)
--gotLevel2 = true
XP.Value = 0
Stamina.Value = 100
end
end)
local function CheckXp (XP,plr,Stamina)
if XP.Value >= 100 and gotLevel2 == false then
gotLevel2 = true
RepStorage.Evolution.Evolution1EnableGUI:FireClient(plr)
elseif XP.Value >= 500 and not gotLevel3 then
gotLevel3 = true
elseif XP.Value >= 1500 and not gotLevel4 then
gotLevel4 = true
elseif XP.Value >= 5000 and not gotLevel5 then
gotLevel5 = true
end
end
Players.PlayerAdded:Connect(function(plr)
local leaderstats = plr:WaitForChild("leaderstats")
local XP = leaderstats:WaitForChild("XP")
local Stamina = leaderstats:WaitForChild("Stamina")
XP.Changed:Connect(function()
CheckXp(XP,plr,Stamina)
end)
RunService.Heartbeat:Connect(function()
if Stamina.Value > 100 then
Stamina.Value = 100
end
end)
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
hum.Died:Connect(function()
--//reset vars
gotLevel2 = false
gotLevel3 = false
gotLevel4 = false
gotLevel5 = false
end)
end)
end)
``
