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

aaaawhy my value changing script is not working?

Asked by 4 years ago

so i made a simple script which changes a value to player items amount.

local value = script.Parent
local plrname = game.Workspace:WaitForChild("PlayerName")
local plr = game.Players:WaitForChild(plrname.Value)
local inv = plr:WaitForChild("Inventory")
while true do
    wait(0.5)
    value.Value = #inv:GetChildren()
end

why its not working

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I think the problem is that Inventory isn't a valid member of the player. Instead, try using Backpack. Also, I would use the PlayerAdded event. This is the script I would use:

local value = script.Parent
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    local backpack = player:WaitForChild("Backpack")

    local function checkForItems()
        while true do
            wait()
            value.Value = #backpack:GetChildren()
        end
    end

    spawn(checkForItems)
end)
0
inventory is a custom folder TFlanigan 86 — 4y
0
i changed backpack to the custom inventory and still not working TFlanigan 86 — 4y
0
Is it a ServerScript? youtubemasterWOW 2741 — 4y
0
umm no idea what serverscript is im kinda new at scripting but i guess its a normal script so - yes TFlanigan 86 — 4y
0
Then idk why it's not working. youtubemasterWOW 2741 — 4y
Ad

Answer this question