Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to check a player slots?

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

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!

3 comments

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.

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.

0

If they drop it cause i have the check on the equip now.

This discussion is preserved as it was. New answers, comments, and votes are closed.