what i am trying to achieve is making a tool handle lit up when you are inside of a not-colliding part (zone) and stop it if you leave it.
Try using the proximity prompt feature
what?? no this is not how it works.
Oh, like the tool tips like a light and it lights up when you’re close?
local distance = (Character.PrimaryPart.Position - part.Position).Magnitude
if distance < part.Size.Magnitude then
–whatever you want to happen
end
this code detects when you get close to an object named “part”
just change variables and add RenderStepped if your code is on a local script or HeartBeat if it is on Server
how do i check when the player activates a tool in that distance?
local distance = (Character.PrimaryPart.Position - part.Position).Magnitude
if distance < part.Size.Magnitude then
–whatever you want to happen
end
fire this when the player activates the tool and check if distance is within the desired range
Use a touch interest type script that fires a remote event that signals a int value to enable, which if it’s enabled, print that they’re using a tool.
how do i detect if a plaayer uses a tool while in that range? without touching events?
and also without raycasting? is that possible?
local distance = (Character.PrimaryPart.Position - part.Position).Magnitude
if distance < part.Size.Magnitude then
–whatever you want to happen
end
fire this when the player activates the tool and check if distance is within the desired range
here
is this eficent if i want to make enemies chack if hit by sword? i mean if they close enough?
yup, you can check every time a frame renders if you’re close enough to your enemy to hit him
btw this isn’t laggy unless you run a super complex code
and how to hit him then? how fo i connect multiple spawning enemies to multiple possibler players that hit it?
in this case you can get a table with all the enemies on a localscript.
Then check if your player is close to any of them using a for loop and if they are you can know exactly what enemy you’re close to and fire a RemoteEvent to damage him
any way without localscript? or aint that possible?
it is however it might be a little bit laggy
so how do i do it? so how do i do it?
i need the enemy after it spawned to automatically be connected to events (using objectvalues?)