Help With Range

Help With Range

LocalScript:

--LOCAL

local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("Hitted12")

local players = game:GetService("Players")
local plr = players.LocalPlayer
local mouse = plr:GetMouse()

local tool = script.Parent

tool.Activated:Connect(function()
	if mouse.Target and script.Parent.Handle.Touched then
		remote:FireServer(mouse.Target, mouse.Hit)
	end
end)

i tried to make range on my own but it doesn’t work
any help will work

Can you go more in depth on what you mean by “range” here?

Touched is an event and cannot be used in conditional statements.

1 Like

i figured it out by myself
here is my local script:

-- Script

local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("Hitted12")

local players = game:GetService("Players")
local plr = players.LocalPlayer
local mouse = plr:GetMouse()

local tool = script.Parent

tool.Activated:Connect(function()
	if (plr.Character.HumanoidRootPart.Position-mouse.Hit.p).magnitude <= 3 then
		remote:FireServer(mouse.Target, mouse.Hit)
	end
end)