So i've been trying to script a slot system to check if a person has a weapon or in this case, flashlight and or deagle?
I've tried the
while true do
but this resulted in a crash. Odd?
--Variables--
flashlight = game.Players.LocalPlayer.Backpack:FindFirstChild("Flashlight")
deagle = game.Players.LocalPlayer.Backpack:FindFirstChild("Deagle")
slot1 = game.Players.LocalPlayer.PlayerGui.Backpack.Backpack.Slots.Slot1
slot2 = game.Players.LocalPlayer.PlayerGui.Backpack.Backpack.Slots.Slot2
--Functions--
if flashlight then
print("Player has a Flashlight!")
slot1.Text = "Flashlight"
elseif flashlight == nil then
print("No Flashlight Found!")
slot2.Text = "Empty Slot"
if deagle then
print("Player has a Deagle!")
slot2.Text = "Deagle"
elseif deagle == nil then
print("No Deagle Found!")
slot2.Text = "Empty Slot"
end
end
So what im trying to do is make the script keep re-checking the player's slots and see if they sitll have the item without lagging the server?
So if anyone could help me? That be great.
Thanks in advanced?
NEW ISSUE
With the help of you guys, it seems to work to a point,
--Variables--
flashlight = game.Players.LocalPlayer.Backpack:FindFirstChild("Flashlight")
deagle = game.Players.LocalPlayer.Backpack:FindFirstChild("Deagle")
slot1 = game.Players.LocalPlayer.PlayerGui.Backpack.Backpack.Slots.Slot1
slot2 = game.Players.LocalPlayer.PlayerGui.Backpack.Backpack.Slots.Slot2
--Functions--
if flashlight and deagle then
print("Player has a Flashlight!")
slot1.Text = "Flashlight"
print("Player has a Deagle!")
slot2.Text = "Deagle"
while wait() do
game.Players.LocalPlayer.Backpack:FindFirstChild("Flashlight")
slot1.Text = "Empty Slot"
game.Players.LocalPlayer.Backpack:FindFirstChild("Deagle")
slot2.Text = "Empty Slot"
end
end
Now the issue is, even though the player has the items, it will still return "Empty Slot"

3 comments
I tried an "and" statement for this to check their character for when it's equiped but it checks both....Anything i can do?
replace with "or"
Thanks!