Why is this script not working? It’s supposed to be if the player has the red soda, then it will print something (I will add the other code myself.)
local CD = Instance.new("ClickDetector")
CD.Parent = game.Workspace.Stove.Heat1Clicker
CD.MouseClick:Connect(function(player)
EB_clickedPlayer = player
local Backpack = EB_clickedPlayer.Backpack
local Red = EB_clickedPlayer.Backpack:WaitForChild("Red Soda")
if EB_clickedPlayer.Backpack:WaitForChild("Red Soda") then
print("a")
end
end)
try Findfirstchild like mentioned above this is cleaner version of your code. you don’t need to set all those extra varaibles
local CD = Instance.new("ClickDetector", game.Workspace.Stove.Heat1Clicker)
CD.MouseClick:Connect(function(player)
local RedSoda = player.Backpack:FindFirstChild("Red Soda") -- just try to find if not there then RedSoda will be nil
if RedSoda then
print("Found RedSoda")
else
print("Cant Find RedSoda")
end
end)
local CD = Instance.new("ClickDetector")
CD.Parent = game.Workspace.Stove.Heat1Clicker
CD.MouseClick:Connect(function(player)
EB_clickedPlayer = player
local Backpack = EB_clickedPlayer.Backpack
local Red = EB_clickedPlayer.Backpack:FindFirstChild("Red Soda")
if Red then
print("a")
end
end)