I'm still trying to figure out a way to add parts with a specific tag to a raycast exclusion list. There is a part that is cloned upon a player joining in a script within ServerScriptService, which is given the tag of "Cursor" since it will follow the player's mouse to act as a cursor visualizer. However, the local script that calculates the player's cursor position in a 3D space will still collide with the cursor part, which causes it to fly towards the camera. I need to find a way to get the tag of the object into the local script, so I can input it into the raycast filter and have it be excluded.
#How to make a table from a server script accessible in a local script
1 messages · Page 1 of 1 (latest)
iirc, the issue with the cursor going to your camera is because you didn’t exclude the workspace.CurrentCamera in your local script
no, the issue is the cursor object
because it's not being excluded by the raycast, the raycast hits it and causes it to update its position onto itself
though someone else mentioned that i could just add the cloned part to a table and see if i could just exclude the contents within the table as a whole
only issue is that the local script is unable to access the table within the server script
I figured i could use a remote event for it but im not sure how to transfer a table via a remote event
How to make a table from a server script accessible in a local script
You could pass the table as an argument for the remote event no?
yeah i suspected that. only issue is what i was trying to do was yielding no results
basically, table name is passed as parameter
but then trying to do anything with that in the local script wouldnt give me anything
wdym? You mean like there is no arguments being passed?
lemme try passing the table into the local script via a remote event again cuz theres a good chance i was doing it wrong
i likely did this wrong
but i tried to make a variable out of the table passed from the server script, and then looping and printing to make sure it was actually getting the contents
but the loop yielded nothing as v is apparently nil
try using local getCursorTable
outside of the function
actually the for loop has to be inside the event
because there is no variable called getCursorTable when you call the for loop
when you are using fire client, you need to have the player recipient as the first argument
then your additional arguments after
now its saying it wants the player argument to be an object
yeah so probably put that line into the event when you called the server
and pass the player argument that you received
ok, so no issue on the client's end. now its the server
unable to cast value to object
the thing is, cursorTable is a table (line 4)
so idk why its not passing through correctly
yup, it worked!! but....
the event might have not been loaded on the client
so you have to use waitforchild
for the event
so....where would i put that exactly?
can i make the RaycastExcludeMousePart wait for child??
yes you wait for the event to load using WaitForChild
something like game.ReplicatedStorage:WaitForChild( event name here)...
yeah im clearly just doing this wrong lol
oh you have to wait for the RaycastExcludeMousePart
i hate that i basically have to have my hand held when writing this stuff out cuz i keep somehow screwing up basic instructions
you have to close the parenthesis
** You are now Level 4! **
i think it would be best if you were to keep scripting to watch tutorials or do mini side projects
to help with understanding
i have been doing that but my issues are so like weirdly specific
cuz i will search for like 20 minutes on google or roblox studio forum posts before making one here myself
WaitForChild(" {string here} ")
you just need to close the string with a parenthesis
oh
well, there's no more syntax errors, but the thing still won't print
the console should output "iDrizzyB's mousePart," as that exact same code nested within the server script works as intended and outputs that
can you print something when the client event is fired then let me know if it works?
ah you commented the variable but it doesnt matter
you can use the cursorTable variable instead of the getCursorTable in the loop
why do you need this on the server exactly?
i commented because i knew it wouldn't print anything, and as i suspected, nothing happened once again
player joins, object is cloned into workspace on server so it can be seen by all players
what are you trying to do
i'm guessing you're trying to move this mousepart to follow the player's mouse and show for all players?
its all said here
** You are now Level 7! **
correct
instead of just (getCursorTable) try pairs(cursorTable) in the for loop
where are you setting position? i see a bit of this render() function that looks like it has mouse ray stuff in it, can you show this function?
pairs(cursorTable)
i see
OHHH i cannot read
so really what the problem is you are having a hard time getting a reference to this object on the client for mouse ray
darn, still nothing....
i just wanna have the mousePart excluded from the raycast so the issue i showed above stops happening
this
but since it is a cloned object, i figured i'd add it to table, and have the contents of the table be raycast-excluded
the thing about doing this in PlayerAdded is that the part is being cloned at the same time as you are firing it to the client, it is unlikely for the part to exist on the client yet (thus it will be nil) and also unlikely for that event to be connected on the client when you fire it, so it's a 2-fold problem there. personally, the simplest way I would do it is to use an ObjectValue set to point to this cursor, or on the client you can workspace:WaitForChild(LocalPlayer.Name .. "'s mousePart") for example
alright, i'll try that
alright, so the wait for child thing did yield a result on the client's end
but, what's this ObjectValue thing? never heard of it before
its like an intvalue/stringvalue like you would use in leaderstats, except it holds an instance value, kind-of like a pointer
i'll make sure to read the documentation on pointers then, since i've never heard of that either☠️
you can set the value on the server and this will replicate to client when the client receives the instance
ahh
a pointer is exactly what it says on the tin - it points to something
so...is it like the tagging thing that comes with collectionService??
kind-of
it doesn't alter the instance in any way
objectvalues are good if you need a reference to some arbitrary instance, like your mouse pointer for example
does it bypass the whole local script thing? can it be accessed from multiple scripts?
coz you can set the value on the server and if not objectvalue.Value then objectvalue:GetPropertyChangedSignal("Value"):Wait() end myinstance=objectvalue.Value
yes can be accessed from anywhere as long as you have the objectvalue instance first
just one thing i would change with this and that is to make the mousepart a model and set its streaming mode to persistentperplayer and add the intended player to it so it is guaranteed to always exist for that player, if it were up to me i'd probably also set network ownership of the part to that player too so the player can move the part directly for themselves, it's not like you're verifying if the client's ray actually hit anything or is a valid ray result
exploiter could send any position they wanted for their mouse ray and server says yup okay
oh yikes, alright then
but that's all minor details, main thing is the persistentperplayer mousepart model streamingmode https://create.roblox.com/docs/reference/engine/enums/ModelStreamingMode#PersistentPerPlayer
how do i change it from a part to a model?
part.parent=model
or, well, you're cloning from something so just make what you're cloning a model
then use model:PivotTo(cframe) instead of part.CFrame=...etc
but that's just what i would do 🤷
after i inputted this as a variable and added it to the exclusion list, the bug was fixed, so big thanks. but i will continue to look into the streaming mode and model stuff in order to make the cursor exploiter-proof
gotcha
the streaming mode has nothing to do with exploit protection. it's to handle the case for when the player is very far from their cursor part and it streams out so it doesn't exist on the client anymore (normal roblox behavior), model streamingmode is how you change that behavior for specific parts
kind-of annoying how you have to detour through a model to get to it but ehh it's not that bad
ah ok
wait how would do you this
i got the object value working fine
but how do i do the pivotto() thing
because models dont have a position like parts do, they instead inherit their position from their primary part, so you have to use a different method to move it
or cframe the primary part
i had a cframe set up for when the mousePart was a solitary part. should i just revert to that
cuz this isnt working
wait why does the mouse need to be in a model anyways?
this is why
ohhh models have access to streamingmode?
yea can only set it on a model
ohhh.. yeah that is kind-of annoying that you need to detour through a model lol
okie dokie
so, how would i set up a primary part then?
model.PrimaryPart=part cmon bruh https://create.roblox.com/docs/reference/engine/classes/Model#PrimaryPart
yeah i could be googling some of these, u right....