Scripts and localscripts in tool not working at all

Hi! I’m making a tool where it’s supposed to require a module if the equip boolvalue is true and it will print some stuff to indicate that it works.
This is the children stuff image

The localscript:

local uis = game:GetService("UserInputService")
local tool = script.Parent
local moouse = game.Players.LocalPlayer:GetMouse()
local rs = game:GetService("ReplicatedStorage")
local modules = rs.Modules
local fruitmodules = modules.Fruit
local module = require(fruitmodules.Hie)
local Player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)

local function zmove(plr, mouse)
		module["Ice Spike"](plr, mouse)
end

local function xmove(plr)
	print(plr)
end

if script.Parent.Equip.Value == true then
	
	uis.InputBegan:Connect(function(inp )
		if inp.KeyCode == Enum.KeyCode.Z then
			zmove(Player, moouse.Hit)
			print("z move is active")
		elseif inp.KeyCode == Enum.KeyCode.X then
			xmove(Player)
		end
	end)
	
	
end

The script:

tool = script.Parent

local function equip()
	tool.Equip.Value = true
end

tool.Equipped:Connect(equip)

Or do this:

uis.InputBegan:Connect(function(inp )
      if script.Parent.Equip.Value == true then
		if inp.KeyCode == Enum.KeyCode.Z then
			zmove(Player, moouse.Hit)
			print("z move is active")
		elseif inp.KeyCode == Enum.KeyCode.X then
			xmove(Player)
		end
       end
end)

Sry for messed up formatting on mobile rn.

It doesnt set the equip value to true

This is because you’re attempting to change the value of a BoolValue instance from a local script which means the change won’t replicate to the server. To remedy this, change the value from a server script.

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character.ChildAdded:Connect(function(child)
			if child:IsA("Tool") then --you can implement other checks here
				child:FindFirstChild("Equip").Value = true
			end
		end)
		character.ChildRemoved:Connect(function(child)
			if child:IsA("Tool") then --you can implement other checks here
				child:FindFirstChild("Equip").Value = false
			end
		end)
	end)
end)

Bruh, he changed value from script not localscript.

You are trying to find out when the tool is equipped. In the local script you try to find out if it is equipped immediately, so it is probably not equipped at that point. Instead of checking if it’s equipped right away, use this.

What changed?
Here we listen for if the value changes. (If it is equipped or unequipped) Then we disconnect the input function when the bool value is not true.

(Please excuse poor formatting and possible mistakes, I’m on mobile.)

local InputBeganFunction
script.Parent.Equip:GetPropertyChangedSignal("Value"):Connect(function()
	if script.Parent.Equip.Value then
	InputBeganFunction = uis.InputBegan:Connect(function(inp)
		if inp.KeyCode == Enum.KeyCode.Z then
			zmove(Player, moouse.Hit)
			print("z move is active")
		elseif inp.KeyCode == Enum.KeyCode.X then
			xmove(Player)
		end
else
InputBeganFunction:Disconnect()
	end
end)