game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(play,mousehit) local a = hum:LoadAniamtion(Tool.Throw) a:Play() wait(0.7) root.CFrame = CFrame.new(root.Position,root.Position + mousehit.lookVector) local fireball = Tool.Handle:Clone() fireball.CFrame = Tool.Handle.CFrame local bv = Instance.new("BodyVelocity") bv.MaxForce = Vector3.new(1e8,1e8,1e8) bv.Velocity = mousehit.lookVector * 50 bv.Parent = fireball fireball.CanCollide = false fireball.Parent = game.Workspace end)
at line 1 where it saids game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(play,mousehit) you know how next to the functions theres (function(play,mousehit)
I don't get what it means like is that a variable how does it work?
When firing a remote event from a Client to Server, you use OnServerEvent on a server-side script to listen for the fired remote event. Data can also be passed along through the firing.
The first paramater in a function connected by the OnServerEvent will always be player. This is because the client of the player is the one that fired it. The arguments that come right after that can be any data type. In your code, it seems that the client is sending the Mouse.Hit value given by the client. You'll have to look for the client code too see if that's true or not.
I can give a simpler example of what's going on and how you can use :FireServer(data).
In a local script:
--Define RE since that's where you keep RemoteEvents/Funcs local ReplicatedStorage = game:GetService("ReplicatedStorage") --Get our event in RE local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent") --In a client script; we do not have to pass "player". The server-script will see that already --All we need is the data we want to pass along to the server --I want to pass a BrickColor remoteEvent:FireServer(BrickColor.new("Bright blue"))
In a Script:
--Defining the same as before local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent") --In my script, all I really want is my passed color. --But if there's any more data being passed, 'arg2' will store that data --Notice we need to have 'player' argument set here remoteEvent.OnServerEvent:Connect(function(player, color, arg2) print(player.Name.." is the one that fired this event!") workspace.Baseplate.BrickColor = color end)
This is basically what's going on in your code and how Client to Server communication works. It's the same going Server to Client. In your case, you'll need to find the local script that's passing "mousehit" to the remote event.