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

Stat Sheet script for basketball isn't working?

Asked by 5 years ago
Edited 5 years ago

So, I made this script, well me and my friend BUT when i try to load it in inside studio and didn't work. However when my friend tries it, it works for him. Any help? Also API services are enabled

-- Server Script
local ds = game:GetService("DataStoreService"):GetDataStore("YourDataStore")
local plrs = game:GetService("Players")
default = {
    reb = 0,
    pts = 0,
    ast = 0,

    banned = false
}

_G.sessionData = {}
local sesData = _G.sessionData

function setupData(key)
    print("Setting up plr data")
    local succ, data =  pcall(function() return ds:GetAsync(key) end)
    if succ and not data == nil then
        sesData[key] = data
    else
        ds:SetAsync(key, default)
        sesData[key] = default
        print("New player")
    end
end

game.Players.PlayerAdded:connect(function(plr)
    local key = plr.UserId
    setupData(key)
    local data = sesData[key]

    if data.banned == true then
        print(key, "is banned.")
        plr:Kick("You are banned:", data.banId)
    end
end)

local function returnd(plr, key)
    local toRet = sesData[key]
    if toRet == nil then return nil end
    print("He is here")
    return toRet
end

game.ReplicatedStorage.RetrieveData.OnServerInvoke = returnd

Local

-- Local Script
local PF = game:GetService("ReplicatedStorage").Players
local AST = script.Parent.ForEveryone.Cater.ECT.Players.StatClone.AST
local PTS = script.Parent.ForEveryone.Cater.ECT.Players.StatClone.PTS
local REB = script.Parent.ForEveryone.Cater.ECT.Players.StatClone.REB
local NAME = script.Parent.ForEveryone.Cater.ECT.Players.StatClone.NAME
local PlayerFrame = script.Parent.ForEveryone.Cater.ECT.Players

delay(1, function() 
    local data = game.ReplicatedStorage.RetrieveData:InvokeServer(game.Players.LocalPlayer.UserId)
    if PF:FindFirstChildWhichIsA("StringValue") then
        local folderstats = Instance.new("Folder",PlayerFrame)
        folderstats.Name = game.Players.LocalPlayer.Name

        local NameClone = NAME:Clone()
        NameClone.Parent = folderstats
        NameClone.Text = game.Players.LocalPlayer.Name
        NameClone.Visible = true
        NameClone.TextScaled = true

        local AstClone = AST:Clone()
        AstClone.Parent = folderstats
        AstClone.Text = data.ast
        AstClone.Visible = true

        local PtsClone = PTS:Clone()
        PtsClone.Parent = folderstats
        PtsClone.Visible = true
        PtsClone.Text = data.pts

        local RebClone = REB:Clone()
        RebClone.Parent = folderstats
        RebClone.Visible = true
        RebClone.Text = data.reb
    end
end)

ps. if I did something wrong or what ever be sure to leave a comment.

0
Line 45 on your script, it says returnd. Is that what its supposed to be? User#22722 20 — 5y
0
Yeah WillBe_Stoped 71 — 5y
0
You have to have a published game to ROBLOX and under Configure Game settings, make sure `Enable Studio Access To API Services` is checked hellmatic 1523 — 5y
0
I already done it WillBe_Stoped 71 — 5y
View all comments (2 more)
0
Don't use _G, use module scripts or bindables. User#19524 175 — 5y
0
thats the thing. It works for my friend but doesnt work for me WillBe_Stoped 71 — 5y

Answer this question