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 to increase the value of XP however it increases multiple times
-
What is the issue? Include screenshots / videos if possible!
However it increases multiple times as you can see via the printing.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Tried discord + youtube + devhub
Local script:
endoflevel.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") and db == false then
db = true
print("IF MULTIPLE LEAVE")
hrp.CFrame = game.Workspace.SpawnLocation.CFrame * CFrame.new(0, 5, 0)
if levelstarted ~= nil then
local timer = os.clock() - levelstarted
timer = timer * 1000
timer = math.round(timer)
local other = timer
timer = timer/1000
timetxt.Text = "Time: "..timer
levelstarted = nil
if tonumber(txt.Text) == 0.0000 then
txt.Text = tostring(timer)
event:FireServer(timer, key, num)
task.wait(2)
--valincrease:FireServer(plr.leaderstats.Level.Value, XP, Coins, other)
valincrease.OnClientEvent:Connect(function(NewCoins, NewXP)
coinstxt.Text = "Coins gained: ".. NewCoins
xptxt.Text = "XP gained: ".. NewXP
rewards.Visible = true
end)
task.wait(2)
db = false
elseif tonumber(txt.Text) > timer then
txt.Text = tostring(timer)
event:FireServer(timer, key, num)
task.wait(2)
-- valincrease:FireServer(plr.leaderstats.Level.Value, XP, Coins, other)
valincrease.OnClientEvent:Connect(function(NewCoins, NewXP)
coinstxt.Text = "Coins gained: ".. NewCoins
xptxt.Text = "XP gained: ".. NewXP
rewards.Visible = true
end)
db = false
else
print("Value increase")
valincrease:FireServer(plr.leaderstats.Level.Value, XP, Coins, other)
valincrease.OnClientEvent:Connect(function(NewCoins, NewXP)
coinstxt.Text = "Coins gained: ".. NewCoins
xptxt.Text = "XP gained: ".. NewXP
rewards.Visible = true
end)
task.wait(2)
end
task.wait(5)
db = false
end
end
end)
Server Script:
valincrease.OnServerEvent:Connect(function(plr, Level, XP, Coins, other, num)
if db1 == false then
print("fird")
db1 = true
for i, v in ipairs(PlayerTimes) do
if i == num then
if v > other then
print("1)"..XP)
local multipler = Level/4
multipler = math.floor(multipler)
XP *= multipler
print("2)"..XP)
Coins *= multipler
math.round(XP)
print("3"..XP)
math.round(Coins)
plr.leaderstats.XP.Value += XP
plr.leaderstats.Coins.Value += Coins
valincrease:FireClient(plr, Coins, XP)
end
else
print("1)"..XP)
local multipler = 1
XP *= multipler
print("2)"..XP)
Coins *= multipler
math.round(XP)
print("3)"..XP)
math.round(Coins)
plr.leaderstats.XP.Value += XP
plr.leaderstats.Coins.Value += Coins
valincrease:FireClient(plr, Coins, XP)
end
end
task.wait(3)
db1 = false
end
end)
It has nothing to do with the local script (i believe) firing the event multiple times because i already used printing to debug it however the server script seems to run multiple times though.
Thanks for the help!