How should i do this?

original title, huh? basically, i have a flaregun tool, but i want the tool to only work if the player has another item, ive tried many things like disabling an enabling the flaregun script from another script detecting if a certain tools parent is = to the character, here is most of the script (server script in the tool):


local IsReady = true
local Module = require(game.ServerScriptService.FlareGun)
local EnforcementRandom = math.random(1, 3)
local Enforcement1 = workspace.Folder.FlareEnforcement1
local Enforcement2 = workspace.Folder.FlareEnforcement2
local Enforcement3 = workspace.Folder.FlareEnforcement3
local FlareContactUI = game:GetService("StarterGui").FlareContact
local TweenService = game:GetService("TweenService")


local Character
local Humanoid 

local Flare = workspace.Flare



function BodyVelocityFlare()
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.MaxForce = Vector3.new(400000, 400000, 400000)
BodyVelocity.P = 10000
	BodyVelocity.Velocity = Vector3.new(0, 100, 0)
	BodyVelocity.Parent = Flare.Handle
end

script.Parent.Equipped:Connect(function()
	Character = script.Parent.Parent
	Humanoid = Character.Humanoid
	

local FlareReloadAnim = Humanoid.Animator:LoadAnimation(script.Parent.FlareReload)
	local FlareShootAnim = Humanoid.Animator:LoadAnimation(script.Parent.FlareShoot)
	
	FlareContactUI.TextLabel.Visible = true

script.Parent.Activated:Connect(function()
	if IsReady == true then
		IsReady = false
		script.Parent.Handle.Load:Play()
		FlareReloadAnim:Play()
			FlareReloadAnim.Stopped:Connect(function()
				FlareShootAnim:Play()
			end)
			
			FlareShootAnim.Stopped:Connect(function()
				script.Parent.Handle.Fire:Play()
				BodyVelocityFlare()
			end)
			
		wait(10)
		if EnforcementRandom == 1 then
				Enforcement1:Play()
				FlareContactUI.TextLabel.Text = "All units, close on suspect."
				tween2:Play()
				wait(10)
				tween:Play()
		end
		if EnforcementRandom == 2 then
				Enforcement2:Play()
				FlareContactUI.TextLabel.Text = "Contact  Confirmed."
				tween2:Play()
				wait(10)
				tween:Play()
		end
		if EnforcementRandom == 3 then
				Enforcement3:Play()
				FlareContactUI.TextLabel.Text = "Target compromised, move in-move in."
				tween2:Play()
				wait(10)
				tween:Play()
		end
			
		Module.HelicopterCall()
		--[[Module.CallDrop(
		 {
			script.Parent,
			script.Parent.Handle.Position,

		}
		
		)
		--]]
		IsReady = false
	end
	end)
	end)
(on the side, there is another problem where a UI with a text label should show up but it doesnt, i removed the tweens but ill add them back if asked)
if script.Parent.Parent:FindFirstChild(other tool) then

thats the same as finding the Flare tool in workspace

Oops. Don’t know why I tried to get the backpack like that…

local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
if player.Backpack:FindFirstChild(other tool) then

This is if you want to check the players inventory for another item, allowing the tool to fire. Put that argument with “if isReady”

there is no variable for the local player as it is a server script

wouldnt that get a single player or a random player in the workspace?

Script.Parent.Parent refers to the character holding the tool. You can get the player using the character.

only if the tool is equipped, the tool is in workspace

I’m saying to put these when the tool is activated. If it’s activated, it’ll be under the character.

how should i disable the Flare from working, since thats what the post is

After the tool is equipped and you define Character. Get the player using
local Player = game.Players:GetPlayerFromCharacter(Character)
then the backpack
local Backpack = Player.Backpack
since its usually not possible to have two tools equipped at once you have to look in the backpack.
Then after the tool is activated, instead of
if IsReady == true then
do:
if IsReady == true and Backpack:FindFirstChild("otheritem") then
(of course “otheritem” being the name of the item you need to use it)

1 Like

what about this? these are the tweens:

	local tweenInfo = TweenInfo.new(
		1, -- Time
		Enum.EasingStyle.Quad, -- EasingStyle
		Enum.EasingDirection.InOut, -- EasingDirection
		0, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
	)

	local tween = TweenService:Create(FlareContactUI.TextLabel, tweenInfo, {Transparency = 1})
	
	local tweenInfo = TweenInfo.new(
		1, -- Time
		Enum.EasingStyle.Quad, -- EasingStyle
		Enum.EasingDirection.InOut, -- EasingDirection
		0, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
	)

	local tween2 = TweenService:Create(FlareContactUI.TextLabel, tweenInfo, {Transparency = 0})

could it be because i called the UI from starter gui?

Yes, you need to get the ui like this:
local FlareContactUI = Player.PlayerGui.FlareContact
Also i think RepeatCount needs to be -1 or lower to repeat forever

when it tweens the textlabel, this is what it should look like:


but this is what it looks like: