Hello Dear Creators, I was trying to make a Leveling System but it wouldnt work. My Issues: It’s not adding the Level also if goal (aka: needed) reached its required clicks. Its also not giving a new goald (aka: newneeded) to be replaced with. If there is a fix for this please let me know in what lines is a misstake since output says nothing. Here’s my SSS Script aswell as Local Script:
Local Script:
local rep = game:GetService("ReplicatedStorage").Level.LevelUp
local levels = game.Players.LocalPlayer.leaderstats.Level
local clicked = game.Players.LocalPlayer.Clicked
local config = script.Parent.Config
local needed = config.Needed.Value
local LevelLable = game.Players.LocalPlayer.PlayerGui.LevelGui.TextLabel
local debounce = false
if levels.Value == 0 then
LevelLable.Text = "Level "..levels.Value.." - "..clicked.Value.."/"..needed.." Clicked."
end
clicked:GetPropertyChangedSignal("Value"):Connect(function()
LevelLable.Text = "Level "..levels.Value.." - "..clicked.Value.."/"..needed.." Clicked."
if levels:GetPropertyChangedSignal("Value") then
if debounce then
print("debounce")
return
end
levels:GetPropertyChangedSignal("Value"):Connect(function()
debounce = true
rep:FireServer(needed)
wait(0.2)
local newneeded = (needed * 2)
needed = newneeded
debounce = false
end)
end
end)
SSS Script:
local rep = game:GetService("ReplicatedStorage")
rep.Level.LevelUp.OnServerEvent:Connect(function(player, needed)
local leaderstats = player:WaitForChild("leaderstats")
local clicked = player:WaitForChild("Clicked")
local levels = leaderstats:WaitForChild("Level")
if clicked.Value >= needed then
print("Player has enough")
levels.Value += 1
end
end)
Do you already know how to use remote events? If not I recommend searching for tutorials at the dev forum or YouTube because it’s a little bit complicated and I don’t know if I’ll be able to explain it to you. (I had a hard time understanding it a few years ago, and I’m really bad at explaining concepts)
If you already know then just go where you change the “clicked.Value” and do a yourRemoteEvent:FireServer(clicked.Value), intercept that information in a server script and you’re good to go.
Hello, I am surely using remoteEvent but i cant link it in the script rn since im currently on phone and its kinda hard to do so! I also know how to use is and im preaty sure you just do the remoteEvent:FireServer(...) Before the whole code or better to say after the function thing but my issue is the function because i do not know with what i could replace it and i tought of that but it did not work out too well so if there is any other option to change the function to let me know!
local remoteEvent = --path to your remote event
clicked:GetPropertyChangedSignal("Value"):Connect(function()
remoteEvent:FireServer(clicked.Value)
-- rest of the code
end
then at your server script add the following function:
local remoteEvent = -- path to you remote event
local clicked = player:WaitForChild("Clicked")
remoteEvent.OnServerEvent:Connect(function(player, updatedValue)
clicked.Value = updatedValue
-- updated value = clicked.Value but the client version of it that was
-- previously sent as an argument with remoteEvent:FireServer(clicked.Value)
end
Btw the names of the remote events and the variables are all up to you if you want to specify what purpose the remote event is serving, for example naming the remoteEvent variable to clickValueEvent or something like that
However
if you can’t link a remote event to your scripts then your best bet is making everything local (turning the server scripts into local scripts) just for testing the learderstats
(Just for testing because this is really bad in an actual online game because each player will see only their stats and the other players’ stats will be all 0, or the default value they are set in the explorer)
How are you using roblox studio on your phone? I didn’t even knew this was possible