Hello, im making a inventory system and im trying to make if where if u press F and the LastToolEquipped Value =='s Nil then ur current light unequips to nothing, but if it doesn’t == nil then your last tool equips, currently i only have it where if u press F it unequips to nothing, when i tried to script it it made the whole thing not work. If you confused tell me and i will explain better
local player = game.Players.LocalPlayer
local character = player.Character
local selected = script.Parent.Parent.Frame.Handler.Selected
local LastEquippedTool = script.Parent.Parent.Frame.Handler.LastEquippedTool
Plr:GetMouse().KeyDown:Connect(function(E)
if E == "f" then
local equipped = script.Parent.Parent.Frame.Handler.Equipped
local LastEquipped = script.Parent.Parent.Frame.Handler.LastEquippedLight
if script.Parent.Parent.Delay.Value == false then
if script.Parent.Equipped.Value == true then
if equipped.Value ~= LastEquipped.Value then
script.Parent.Parent.Delay.Value = true
character.Humanoid:UnequipTools()
script.Parent.Parent.Frame.Handler.Equipped.Value = nil
script.Parent.Equipped.Value = false
wait(1)
script.Parent.Parent.Delay.Value = false
script.Parent.Unequipped.Disabled = false
script.Disabled = true
else
local equipped1 = script.Parent.Parent.Frame.Handler.Equipped
local LastEquipped1 = script.Parent.Parent.Frame.Handler.LastEquippedLight
if script.Parent.Parent.Delay.Value == false then
if equipped1.Value == LastEquipped1.Value then
character.Humanoid:UnequipTools()
script.Parent.Parent.Delay.Value = true
script.Parent.Parent.Frame.Handler.Equipped.Value = nil
script.Parent.Parent.Frame.Frame.Equip.Text = "Equip"
script.Parent.Equipped.Value = false
wait(1)
script.Parent.Parent.Delay.Value = false
script.Parent.Unequipped.Disabled = false
script.Disabled = true
end
end
end
end
end
end
end)
Sorry I explained this very bad, I’m trying to make it where if u equip a tool the tool will go into a object value, if you Click F which F equips a light source u equip ur lantern but here’s what I want to change, I want to make it where if the value for the LastToolEquipped == false then when u press F it equips to nothing, but if it doesn’t == nil and u Press F then instead of equipping to nothing it equips to the LastToolEquipped
The script I put in the post fully works just without the feature I wanted, if u press F ur lantern equips, press it again your lantern goes away all I want to change is if there is a value for LastEquipedTool then it equips it instead of ur lantern going away, if there isn’t a value then the script works the exact same as u press F ur lantern equips, press it again your lantern goes away, idk where to put the If statement in the script tho, last time I tried the script no longer works. Do you get what I’m saying?
Shouldn’t this be all you need if the script is working as you stated? Assuming “LastEquipped1” is an ObjectValue instance of which its value is a reference to the Tool instance itself which was most recently equipped.