I am stuck on the first script, which I have in my ball as a localscript, since ordinary scripts cannot get a player’s mouse, how would I use RemoteEvents to run the script and make the ball show up on other player’s screens?
So remote events are easy to use.
Whenever the mouse input is detected, fire a remote event.
Let me show.
game:GetService("UserInputService").InputBegan:Connect(function(input) -- Argument / Parameter input
if input.KeyCode == Enum.KeyCode.E then -- If player pressed "E"
game.ReplicatedStorage.EVENT:FireServer(input) -- in brackets you can put the input needed
end
end)
You can obv send every argument you want in the brackets, after that you add a SCRIPT in serverscriptservice which does this:
--Detects when remote event is fired, this is now a Server Script, everything you put here will be visible for ALL players
game.ReplicatedStorage.EVENT.OnServerEvent:Connect(function(player,input, {...all other args})
print(input) -- will print the input, the print signal will be "green" that means its a server print
end)
I hope this helped!
Additionally you could add mouse coordinates too, insert a Vector3 value in a variable, and send the data as argument to the firing function, and the game is done!
Reply back if you still need help!
How can I insert the Vector3 value in a variable?
just do this
local VARNAME = Vector.new(x,y,z)
print(VARNAME) – Will print 3 values
print(VARNAME.x) – Will print the “x” value of the vector
but then how would I get the information from the print in the local script to be used in the server script?
1 Like