Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My EXP / Leveling Up System Doesnt Work?

Asked by 1 year ago

im making a system where orbs will spawn at assigned places, when leveled up, it will set exp back to 0, set the level up, add more to the expcap, add more to the jump and speed value and deletes the orb placed, none of it is working though and I need some help

EXP Orb Spawning Script In Workspace

local SpawnAmount = script.Value
local SmallEXP = game.ReplicatedStorage.Small
local SpawnPlaces = workspace.SpawnPlaces:GetChildren()

while SpawnAmount > 0 do
    local clone = SmallEXP
    clone.Parent = workspace
    clone.Script.Enabled = true
    task.wait(1)

    for i = 1, #SpawnPlaces do
        clone.CFrame(i, SpawnPlaces[i].Name).Position
    end


end

Leveling Up System In Workspace

local Players = game:GetService("Players").LocalPlayer
local exp = Players.EXP
local expCap = Players.EXPCap
local remoteEvent = game.ReplicatedStorage.Remotes.LvlUp

while true do
    if exp >= expCap then
        remoteEvent:FireServer()
    end
end

Stat Script In ServerScriptService

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local LvlUp = ReplicatedStorage.Remotes.LvlUp
local SmallEXP = ReplicatedStorage.Remotes.EXP.Small

local humanoid = Players.LocalPlayer.FindFirstChild("Humanoid")
local plr = game.Players:GetPlayerFromCharacter(humanoid)


Players.PlayerAdded:Connect(function(player)
    local speed = Instance.new("IntValue", player)
    speed.Name = "Speed"
    speed.Value = 8
    local jump = Instance.new("IntValue", player)
    jump.Name = "Jump"
    jump.Value = 4
    local exp = Instance.new("IntValue", player)
    exp.Name = "EXP"
    local expCap = Instance.new("IntValue", player)
    expCap.Name = "EXPCap"
    expCap.Value = 100
    local level = Instance.new("IntValue", player)
    level.Name = "Level"
    level.Value = 1
end)

LvlUp.OnServerEvent:Connect(function(player)
    player.Level.Value += 1
    player.EXP.Value = 0
    player.EXPCap.Value += 100
    player.Speed.Value += 0.5
    player.Jump.Value += 1
end)

Script In TextLabel

local Players = game:GetService("Players").LocalPlayer
local exp = Players.EXP
local expCap = Players.EXPCap
local Text = script.Parent

exp.Changed:Connect(function()
    Text.Text = tostring(exp.Value).."/"..tostring(expCap.Value)
end)

1 answer

Log in to vote
1
Answered by 1 year ago
Edited 1 year ago

You are not checking the values of exp and expCap in the while loop. Also, you should be using task.wait() otherwise it will crash.

I presume that the script in the workspace is a local script based on the fact that you did not seem to state anything about the error you would have gotten from trying to compare instances. The reason why it did not error is because local scripts do not run in the workspace. You can use a normal script, and set the RunContext property to the client, or, move the local script somewhere it can run.

I would not recommend doing this on the client, as the client can manipulate the values and fire the remote event to gain an infinite amount of "Levels".

0
which one of the workspace scripts are supposed to be client scripts? JmoneyPlayzOfficial 49 — 1y
0
I'm referring to the "Leveling Up System" script . Ideally, it should not be running on the client as I explained in my answer, but you can move the local script to somewhere like StarterGui for it to run code. xInfinityBear 1777 — 1y
Ad

Answer this question