I am currently making a proximity text-chat feature.
What i want to happen: Raycast from the player to the other player and see if there is a wall in the way
what happens: one player will return a hit, one won’t
code for raycast:
local map = {workspace.Map}
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = map
local ray = workspace:Raycast(headpos,pos,params)
if ray then
print('hit something, dampening')
else
print('nothing hit')
end
Oops, I just realized the map variable was already a table. The origin and direction is probably the issue then. Keep in mind you said “destination point”, when the parameter is actually a direction. That might be the issue. Could you show the variables for the 2 points?
Could I see what the second parameter is the cast function was, the “pos”?
Also, I see some things that aren’t related to the problem that you should change.
Keep remotes in an organized folder in ReplicatedStorage. Your remotes are directly in RS, putting them in a folder is more organized. This avoids having things scattered throughout RS.
Avoid spamming .Parent. Reference to the actual character instead.
You can actually do everything on the client (raycast, npc messages, etc.). This takes some load off the server which will create less lag.
It seems your script is located somewhere inside Workspace inside a character. I wouldn’t do this, as it creates multiple unnecessary scripts. Most of the time you’ll want to put server scripts inside ServerScriptService. This uses one master script instead of multiple duplicated scripts, which again, creates less lag.
These are just some good practices you should get use to, they’ll help you later down the line.