My script is supposed to equip a flashlight every time I hit "f", and remove the flashlight if it is already equipped. It's not working. Can anyone help?
BP = script.Parent -- LocalScript is placed in the player's Backpack.
FL = BP.Flashlight
char = BP.Parent.Character -- Finds character.
Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.KeyDown:connect(function(key)
local a = FL:clone()
if key == "f" and a.Parent == char then
a:remove()
else
a.Parent = char
end
end)

6 comments
It doesn't work and the output doesn't show any errors.
My bad, I forgot an end. Try now.
It still doesn't work. Now the output says "23:56:27.330 - Players.Player1.Backpack.InventoryScript:10: 'then' expected near 'if'".
Fixed. Again, I simply forgot to put a "then"" after an if statement. Update me what the result is.
It works now! Thanks so much!
No problem!