I am trying to make the starter spell from Skyrim called Flames, which fires while you hold mouse and moves the arm towards your mouse position. I am looking for a way to replicate this effect without rapidly firing an event sending mouse position to the server.
I was able to replicate it partially, without making it follow the mouse by creating a loop that stops when player lets go of LMB, however having it follow mouse position is leaving me stumped.
I had an idea of rotating the arm locally and have the loop on server side check it’s position before firing. However unfortunately it doesn’t replicate to the server. I am now wondering if there is another way to do this or is firing the event non stop while player holds the mouse button the only option?
You have to send it to the server to show the arm movement to other players, you have to send the mouse.Hit to the server and set the CFrame there, (or you can have it not show to other players and keep it on the client)
Either way, if it damages, you have to send a remote to damage the player
I think you misunderstood my question. I am asking if there is another way to update mouse position serverside other than constantly firing an event with the mouse position
That’s exactly what I am asking. Is there any other way than the event, by using the things that replicate from local to server or something. I am trying to avoid firing an event every 0.05 seconds because i feel that is not a very performance friendly solution
I don’t think there is a way to get Mouse Position in Server without Remote Events , Since Mouse belongs to the Client and Can be accessed Only via Local Script or a Module Script required by local script.One thing you can do is change the Arm CFrame in the Local Script itself .
One way to do it without a remote is to use physics on a part that the local player can control using :SetNetworkOwner then you can perhaps use that direction of that part.
While part properties do not technically replicate, there are a few exceptions. If the part is created by a client and that client simulates physics (the part falls, hits other objects, moves by constraints, etc.), the resulting changes will get copied to the server.
Otherwise don’t worry about using remote events to communicate this information, it’s just three numbers and it’s what remote events are used for. I believe you are falling for the trap of premature optimization.
Here is a gun firing at 3000 rpm from a well known fps framework tutorial with the following framework sending 2 vectors and a table of gun settings
Well I tried one thing and It got replicated to the Server . GIF , In this GIF Im in the server
and I used this Local Script in the StarterCharacterScripts
wait(5)
local char = script.Parent
local hand = char:WaitForChild('RightHand')
print(hand.Name)
hand.CFrame = hand.CFrame * CFrame.Angles(0,math.rad(45),0)
hand.CFrame = hand.CFrame * CFrame.Angles(0,math.rad(90),0)
hand.CFrame = hand.CFrame * CFrame.Angles(40,math.rad(45),0)
Yeah in the gifs it looks like you are using the CFrames to cause your local character to fling, and because physics gets replicated automatically yeah you can see the effects on the server.
However, as noticed it doesn’t look like your hand is actually moving on the server and it’s still in a default Idle pose. So the CFrame orientation doesn’t get replicated which is expected of the Roblox client server model.
Well actually , its Orientation is not being changed in the Client too , The Client and Server Shows Exact Same result .He wants movement of Hand and I believe it is possible in the Client . Correct me if I am wrong.
Oh yeah if you are changing the CFrame position of the arm which causes the physics to happen then yeah it will replicate technically the “arm” will move because I believe the gif you sent the whole body moves along with the arm that is being rotated which then causes the fling cuz humanoids.
However, if you change the CFrames locally and the part doesn’t undergo an automatic base part physics replication step like the fling that happens in the video then it won’t replicate.
An example would be changing the CFrames of the Motor6D joint in this great video by @okeanskiy which should be similar to the effect of the flames spell from skyrim where you would want your hands and arms to point outwards and what OP wants which yeah will need replication with the help of remote events in order for replication to occur.
I am not sure if i am optimizing prematurely. Whatever I end up using I will be using as a module for all such spells so I wanna get it right from the start. I already achieved channeling by firing event to stop and to start, kinda shame now to change it to firing constantly
I managed to create a script that replicates the rotation of my character’s arm by unsing animations.
I made 2 animations, both lasts 1 second.
The first anim moves as the X vector, it makes the arm face left, and at the end it faces right, so between it has all the interpolation values. The second anim is for the Y vector, character starts facing the arm down and ends facing up.
Then i was able to turn that the desired shoulder (motor6d) X and Y scales, that is usually [-1,1] to these animations’s TimePosition properties, now converted to a [0, 1] scale. With some mind-killer math i managed to make it work perfectly, even when looking behind, and the character even does it with a lot more style.
Animations auto-replicate to the server, setting the time position sussessfully made them replicated.
BUT sure this method wont perfectly replicate the direction the mouse is pointing, only the anim.
Giving the network ownership of a part to a player on the server also looks like a great idea if the BodyMovers wont annoy you.
You can also put the remote calls in a Mouse.Move and Camera.CFrame changed events, plus a debounce and see if it doesnt get too overwhelming to the remote, i mean, its better then using RenderStepped.