How to disable unequipting a flashlight

hello im trying to make it so the player cant unequipt there flashlight since thats not a feature i want. how would i do this?

i tried making an animation and i set the priority to core but it only works when im holding the flashlight and doesnt lock the player from unequipting it.

script: (i put in player scripts)

 local Players = game:GetService("Players")
local Character = Players.LocalPlayer.Character
if not Character then
	Character = Players.LocalPlayer.CharacterAdded:Wait()	
end

local humanoid = Character:WaitForChild("Humanoid")


local myanimegirl = Instance.new("Animation")
myanimegirl.AnimationId = "rbxassetid://8466085144"
local myanimegirltoplay = humanoid:LoadAnimation(myanimegirl)
while true do
	print("Playing")
	myanimegirltoplay:Play()
	wait(2)
end

unequipting the flashlight in my game is malicious and explotious since it ruins the experience unfairly for other players bringing users away from the roblox community and potentially hindering others from experiencing a creative enviroment killing there aspirations and dreams of things like developing for roblox.

this is why its essential this malicious issue needs to be fixed

1 Like

okay so you can Disable the whole Backpack core gui using StarterGui:SetCoreEnabled() i mean yes exploiters can still enable the backpack up again and unequip the tool OR you can use the Tool.Unequipped to check when the tool is unequipped, you can put the tool back in the player’s hand by changing the tool.parent to the player’s character. or you can even use Humanoid:EquipTool() to change the equip their tool once they unequip it?

cant you just do AnimationTrack.Loop and set it to true instiad of doing this?

doing this isn’t really efficient, since this script is located inside StarterPlayerScript correct? okay so the only reason this isnt efficant is becuase a local script fires when the player joins.
i mean yes you have CharacterAdded:Wait() in there but lets say the player respawns the Character variable wont be accounted for since basicly when the character dies and spawns as a character it updates the Player.Character so thats why it isnt accounted for, so this would only run once.

1 Like

wait hold on let me resay everything. how do i make it so the player cant unequipt the flashlight but they are still holding it

what do you mean by AnimationTrack.Loop that property doesnt exist in myanimegirl

exaclty, you can force em to have it equipped. you just gotta check whent hey unequip the tool. with the Tool.UnEquipped. since once its unequipped the tools gets parented inside the player’s backpack. so when its placed into the backpack just place it back into the player’s character instance.

how would i script that?(sorry im not good with this stuff)

AnimationTrack.Looped is an actual property of an animation track mentioned here

i also want it so they cant see the backpack menu as well (like i dont want them to see a icon at bottom of screen)

You can disable the CoreGui, and they are unable to unequip it.

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

Disabling the CoreGui makes the player unable to equip it.

i put this in the animation script as well?

I believe that you can put it in the animation script. But, you can check to be sure.

Wouldn’t players still be able to press 1 and it would unequip the tool?

it disables the backpack but it also disables the flashlight and it becomes unable to use making the game impossible to play

You could set the flashlight’s parent inside of the character.

how so through a script? the players character isnt a model in workspace. how would i make the player hold it

by the way game without a flashlight:

no because the backpack is disabled so you cant equip nor unequip any items at all

The players’ character is actually in the workspace.

Screenshot:
Screen Shot 2022-01-05 at 11.51.06 PM

dude thats your player not mine which is why it wouldnt work

@KrimsonWoIf use his code as its the only way to do it here is how you can do it

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
wait(2)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

That was just an example. Your character’s model should show when playing the game.