Script doesnt print anything

local player = game.Players.LocalPlayer

local Tool = script.Parent

local Equipped = false

local Config = {
	Range = 30;
	IndicatorColors = {
		InRange = Color3.fromRGB(0, 255, 0);
		OutRange = Color3.fromRGB(255, 0, 0);
	}
}

local RangeIndicator = script.Parent:WaitForChild("RangeIndicator")

local Mouse = player:GetMouse()

Mouse.TargetFilter = RangeIndicator

local TeleportEvent = script.Parent.Teleport

Tool.Activated:Connect(function()
	
	local Distance = math.floor((RangeIndicator.Position - player.Character.PrimaryPart.Position).Magnitude)

	if Distance <= Config.Range then

		local Char = player.Character

		local Alive = Char.Humanoid.Health > 0

		if Alive then

			TeleportEvent:FireServer((Mouse.Hit.Position + Vector3.new(0,3,0)))

		end

	end
	
end)

Tool.Equipped:Connect(function()
	
	Equipped = true
	
	RangeIndicator.Parent = workspace
	
	print(Mouse.Hit.Position)
	
	RangeIndicator.Position = Mouse.Hit.Position
	
	print(RangeIndicator.Position)
	
end)

Tool.Unequipped:Connect(function()
	
	Equipped = false
	
	RangeIndicator.Parent = Tool
	
end)

while wait() do
	
	if Equipped == true then
		
		RangeIndicator.Position = Mouse.Hit.Position
		
		local Distance = math.floor((RangeIndicator.Position - player.Character.PrimaryPart.Position).Magnitude)
		
		if Distance <= Config.Range then

			RangeIndicator.Color = Config.IndicatorColors.InRange

			RangeIndicator.Outline.Color = Config.IndicatorColors.InRange

		else

			RangeIndicator.Color = Config.IndicatorColors.OutRange

			RangeIndicator.Outline.Color = Config.IndicatorColors.OutRange

		end
		
	end
	
end

Not only does the script not work at all but it doesnt print anything so i cannot debug

Is this a local script or a normal one?

Check some of your booleans. Maybe the Alive variable doesn’t have to be made, you can simply just check if the health is 0.

...

if Char.Humanoid.Health > 0 then

		TeleportEvent:FireServer((Mouse.Hit.Position + Vector3.new(0,3,0)))

	end

...

this is a local script

(extra text)

I’m making the assumption that your tool has the RequireHandle property set to true without an existing handle? The Equipped, Unequipped, Deactivated, Activated won’t fire if you’ve assembled your tool this way. There is an easy fix, you can either create a Handle part inside of the tool, or set the RequireHandle property to false.

Try setting the RequireHandle property (in the tool) to false.

Okay try setting RequireHandle to false in the tool properties.

this worked!!! thank you (i actually did this myself a few min ago)

İf this local script try to use remote events

You should probably mark the solution so people know this has been solved.

1 Like