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