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

Can you lead me in creating rpg game like?

Asked by 4 years ago

I have done the leader boards already

local level = 1
local exp = 0
local axp = 20

local InStudio = game:GetService("RunService"):IsStudio()

if not InStudio then
    level = game:GetService("DataStoreService"):GetDataStore("Levels")
    exp = game:GetService("DataStoreService"):GetDataStore("EXP")
    axp = game:GetService("DataStoreService"):GetDataStore("AXP") -- Amount of exp needed to level up.
end

function savedata(dataname, playerid, value)
    if InStudio then return end
    dataname:SetAsync(playerid, value)
end

game.Players.PlayerAdded:connect(function(player)
    local leader = Instance.new("Folder")
    leader.Name = "leaderstats"
    leader.Parent = player
    local levelz = Instance.new("IntValue")
    levelz.Name = "Level"
    local xpz = Instance.new("NumberValue")
    xpz.Name = "Exp"
    local xpn = Instance.new("IntValue")
    xpn.Name = "ExpNeeded"

    if not InStudio then
        xpn.Value = axp:GetAsync(tostring(player.userId)) or 20
        xpz.Value = exp:GetAsync(tostring(player.userId)) or 0
        levelz.Value = level:GetAsync(tostring(player.userId)) or 1
    else
        xpn.Value = axp
        xpz.Value = exp
        levelz.Value = level
    end

    levelz.Parent = leader
    xpz.Parent = leader
    xpn.Parent = leader

    xpz.Changed:connect(function()
        if player.leaderstats:WaitForChild("Exp").Value >= player.leaderstats:WaitForChild("ExpNeeded").Value then
            levelz.Value = levelz.Value + 1



            xpn.Value = math.floor(xpn.Value * 2) --You can change this if you want.
            xpz.Value = 0   

            savedata(level, player.userId, levelz.Value)
            savedata(exp, player.userId, xpz.Value)
            savedata(axp, player.userId, xpn.Value)
        else
            savedata(level, player.userId, levelz.Value)
            savedata(exp, player.userId, xpz.Value)
            savedata(axp, player.userId, xpn.Value)
        end
        savedata(level, player.userId, levelz.Value)
        savedata(exp, player.userId, xpz.Value)
        savedata(axp, player.userId, xpn.Value)
    end)
end)

game.Players.PlayerRemoving:connect(function(player)
    savedata(level, player.userId, player.leaderstats.Level.Value)
    savedata(exp, player.userId, player.leaderstats.Exp.Value)
    savedata(axp, player.userId, player.leaderstats.ExpNeeded.Value)
end)

--Animation Script (Local Script)
local player = game.Players.LocalPlayer
local exp = player:WaitForChild("leaderstats"):WaitForChild("Exp")
local axp = player:WaitForChild("leaderstats"):WaitForChild("ExpNeeded")

while true do
    wait()
    local expBarSize = (exp.Value/axp.Value) - 0.02
    if exp.Value == 0 then
        expBarSize = 0
        script.Parent:TweenSize(UDim2.new(expBarSize, 0, 0, 20), "Out", "Quad", 0.25)
    else
        script.Parent:TweenSize(UDim2.new(expBarSize, 0, 0, 20), "Out", "Quad", 0.25)
    end
end

--ExpText Script (Local Script)
local player = game.Players.LocalPlayer
local exp = player:WaitForChild("leaderstats"):WaitForChild("Exp")
local axp = player:WaitForChild("leaderstats"):WaitForChild("ExpNeeded")

while true do
    wait()
    script.Parent.Text = "EXP: " .. exp.Value .. "/" .. axp.Value 
end

--GetLevel Script (Local Script)
local player = game.Players.LocalPlayer
local level = player:WaitForChild("leaderstats"):WaitForChild("Level")

script.Parent.Text = "Current Level: " .. level.Value

level.Changed:Connect(function(value)
    script.Parent.Text = "Current Level: " .. value
end)

--GiveExp Script (Server Script)
local PlayersService = game:GetService("Players")

local function onTouch(hit)
    local player = PlayersService:GetPlayerFromCharacter(hit.Parent)
    local expPoints = player:findFirstChild("leaderstats")
    if expPoints ~= nil then
        local points = expPoints:findFirstChild("Exp")
        if points ~= nil then
            points.Value = points.Value + 5
        end
    end
end

script.Parent.Touched:connect(onTouch)



i want wooden dummy to give the amount of exp when died (like in rpg game :D)

0
I'm gonna try it dood Foxy_Developer 111 — 4y
0
You want the advanced rpg game type like vesteria? St_vnC 330 — 4y
0
i just want the dummy to give exp when killed. but no. just a farming game without quests, maybe with monster drops. a game very similar to infinity rpg bukjesieni -8 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

The answer will be in 1-2 hours

0
Roger that :D bukjesieni -8 — 4y
Ad

Answer this question