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

How to check a player slots?

Asked by 10 years ago

So i am working on a DayZ Slot system, so here's what i got currently.

flashlight = game.Players.LocalPlayer.Backpack:FindFirstChild("Flashlight")
gui = game.Players.LocalPlayer.PlayerGui.Backpack.BackPack.Slots.Slot1
if flashlight then
    print("Player has Flashlight!")
    gui.Text = "Flashlight"
elseif flashlight == nil then
    print("No Flashlight Found!")
    gui.Text = "Empty Slot"
end

I am trying to figure out how it can detect if the weapon is equipped or not? i can not find a wiki for this.

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

When it's equipped, it can be found in their Character.

flashlight = game.Players.LocalPlayer.Character:FindFirstChild("Flashlight")
gui = game.Players.LocalPlayer.PlayerGui.Backpack.BackPack.Slots.Slot1
if flashlight then
    print("Player has Flashlight!")
    gui.Text = "Flashlight"
elseif flashlight == nil then
    print("No Flashlight Found!")
    gui.Text = "Empty Slot"
end

~ Did I help you? Well, help me out by bumping up my reputation/accepting my answer!

0
Ok, so one last question, if you get this next one right i shall. I need to make sure the script can detect when they drop it to set the text to "Empty Slot", i've been trying myself this whole time. TwoSlhue 5 — 10y
0
When they drop it? Or unequipped it? Have a while true do loop and make it check if it's in their Backpack and in their character. If neither, then have it set the text. I don't want to do it for you, because I want you to learn. Shawnyg 4330 — 10y
0
If they drop it cause i have the check on the equip now. TwoSlhue 5 — 10y
Ad

Answer this question