trying to add server sided hitboxes to some hands for vr, and i need to create the hands as a server sided part through a localscript and call said part in the localscript later, how would i go about this? i am a beginner with remoteEvents so i have no clue what im doing even after research
I would recommend taking a look at RemoteEvents since what your trying to do is create a part that everyone can see on a localscript.
Edit: did not read all of it.
-- LocalScript
local event = game.ReplicatedStorage:FindFirstChild("RemoteEvent")
event:FireServer() -- in the brackets put any arguments you want to pass through scripts
-- ServerScript
local event = game.ReplicatedStorage:FindFirstChild("RemoteEvent")
event.OnServerEvent:Connect(function(player) -- Player is always the first argument in a server event
-- Do whatever here
end)
ill get back to you to see wether or not it works, but yeah i never realized you needed player as a thing in them
Maybe you can try creating the hands on the server and controlling them from the client.
Don’t forget to set the network ownership of the hands.
how would i send a local function through the remote event? thats the main problem im having.
Basicly want it to go
client (send 2 local functions) → server (runs said function so the part can move parts on server-side)
Yeah, basicly what im attempting to figure out, and i have a script inside of the hands that has the code
script.Parent:SetNetworkOwner(nil)
event:FireServer(variable.Position)
then on your server script
event.OnServerEvent:Connect(function(player,vPos) -- variable can be named different on server script. With this, it sends the variables position to the server script
But say you wanna send multiple things through a localscript. We can do this
event:FireServer(variable.Position,variable.Size,part.BrickColor) -- sends the variables position, size, and a parts brickcolor
Then on your server script
event.OnServerEvent:Connect(function(player,vPos,vSize,pColor)
You should be setting the network owner to whoever the hands belong to.
HandPart:SetNetworkOwner(Player)
When you set it to nil it means the server is in charge of physics for the hands.
ohh that may be why its buggy, its basicly just the hands collision is screwed up some weird way where it teleports them after a bit as if it were lagging, and i just assumed thats what the problem was
You should set the networkowner of something that a player is gonna control (EX: a vehicle seat, or the players character). If the networkowner was the server, there would be a delay for movement
i just want the “hand” parts to interact with physical parts, and it just does some weird teleport-ish thing, i can see if i can get a video of what i see
Have you tried making the hands collidable themself?
https://cdn.discordapp.com/attachments/842548130469118033/843669735341031464/2021-05-16_20-01-02.mp4
yeah, but thats not the exact problem, i posted the video showcasing what i mean exactly
Maybe the hands are client sided. Try making collision boxes for your hands on a server script? I am not the best with VR stuff.
yeah, i think i just thought of a way to do it
nope, but ill try tomorrow, no clue why it does this
This is just a guess, but maybe you need to set Player.ReplicationFocus.
If Player.ReplicationFocus is set to nil or Player.Character has no PrimaryPart then the player will never ‘own’ the physics for parts near them.
Try setting one of the hands as the replication focus and see if that fixes it (Or if your VR character has one, set it as the head).