Yes, I have CanCollide set to false, but CanTouch and CanQuery are set to True
I assume that DomainEvent
is a RemoteEvent? The syntax for FireClient()
is as follows:
RemoteEvent:FireClient(player : Player, ... : any?)
You must pass a Player object to FireClient()
, and getting the player can be achieved by using Players:GetPlayerFromCharacter()
:
local PLAYERS = game:GetService("Players")
local playerCharacter = workspace.pretendThisIsAPlayerCharacter
print(PLAYERS:GetPlayerFromCharacter(playerCharacter))
For your use case, you may prefer to make use of workspace:GetPartBoundsInRadius().
I believe that this should be much simpler than having to create a sphere each time, and you won’t have to worry about weird .Touched things.
Correct, DomainEvent is a remote event that I’m firing using a tool that’s firing to server. I see what you mean regarding the FireClient, I’ll have to adjust that too. I’m just unsure why my part isn’t being touched in the first place.
I’ve never heard of that before, I’ll have to research that and try it out.
I’ll look into “WorldRoot | Documentation - Roblox Creator Hub” and if that yields any results I’ll come back and let you guys know, thank you all for helping me out
You can try using .Magnitude
for this:
game:GetService("RunService").PreRender:Connect(function()
if ("Sphere" - "HumanoidRootPart").Magnitude <= 1 then
-- Fire Event
end
end)
I’ve heard of magnitude before just never understood it, I guess I have that to look into as well. I’m relatively new to scripting so a lot of things still don’t make full sense to me like what to do and how to do it better and vice versa, so thank you guys for helping me.
Magnitude is basically the distance from the origin to a given vector (vector could represent a velocity, position, etc.)
Oh I see so I set a position and then whatever I make the magnitude, it will basically just detect anything within said radius around my chosen point?
Not quite. Magnitude just returns a number.
I know what KingBlueDash was trying to get to, however his implementation was flawed. I would recommend just sticking to :GetPartsBoundInRadius()
For hitboxes like this I highly recommend using the ZonePlus module by ForeverHD.
From my experience it’s super accurate and has built-in functions for detecting either players (on the server) or localplayer (on the client).
I’ll 100% try that, I’m still new to modules so I don’t really know how they work or even really how to call them. Things like the lightning modules that people use.
I imagine that’s like the other function called like “:GetsPartsInPart”?
Pretty similar yeah. Only difference is that the PartsBoundInRadius one does a spherical area while teh PartsInPart one does a box area (the part that is passed as a parameter to the parts in part function.)
For something like this you would just insert the module in ReplicatedStorage, call it using
Zone = require(ReplicatedStorage:WaitForChild(“Zone”)
and to create the “Zone” (hitbox) do
VoidZone = Zone.new(VoidHitbox)
and replace VoidHitBox.Touched with VoidZone.playerEntered which also returns the player who touched it
From my experience it’s best to avoid touched events wherever possible because they are unreliable/inaccurate. You won’t regret taking the leap to ZonePlus
I’ll also be trying this since that actually makes solid sense in my current standing of knowledge, again thank you all for being so helpful. For my last 6 years of development I had relied on “Hidden Developers” for help and the most I got was ridicule and silence but the help that you guys have given me tonight is more than I’ve recieved in the past 6 years so thank you guys SO much.
I just did this and it was SO simple compared to touch and it actually WORKS! Thank you so much for your help
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.