Transferring parameters from client to server?
Hi, I'm not exactly sure how to transfer parameters from the client to the server via Remote Events. I'm trying to create a laser gun and I pretty much followed the guide on the Roblox Dev website, but instead of using a Local Script I tried to use Remote Events. Here's what I have.
LocalScript:
01 | local tool = script.Parent |
02 | local handle = tool:WaitForChild( "Handle" ) |
03 | local RS = game:GetService( "ReplicatedStorage" ) |
04 | local FlameEvent = RS:WaitForChild( "FlameThrowEvent" ) |
06 | local player = game.Players.LocalPlayer |
07 | local Mouse = player:GetMouse() |
08 | local handlepos = handle.CFrame.p |
09 | local mousepos = Mouse.hit.p |
14 | tool.Activated:connect( function () |
15 | if debounce = = false then |
18 | FlameEvent:FireServer(handlepos, mousepos) |
Server Script:
01 | local RS = game:GetService( "ReplicatedStorage" ) |
02 | local FireEvent = RS:WaitForChild( "FlameThrowEvent" ) |
04 | local DebrisFolder = Instance.new( "Folder" ) |
05 | DebrisFolder.Parent = game.Workspace |
07 | function FireBlaze(player, start, finish) |
08 | local ray = Ray.new(start, (finish - start).unit * 300 ) |
09 | local part, position = workspace:FindPartOnRay(ray, player.Character, false , true ) |
11 | local flame = Instance.new( "Part" ) |
12 | flame.Transparency = 0.5 |
14 | flame.CanCollide = false |
18 | local distance = (start - position).magnitude |
19 | flame.Size = Vector 3. new( 4 , 4 , distance) |
20 | flame.CFrame = CFrame.new(start, position) * CFrame.new( 0 , 0 , -distance/ 2 ) |
22 | flame.Parent = game.Workspace |
23 | game:GetService( "Debris" ):AddItem(flame, . 5 ) |
28 | FireEvent.OnServerEvent:connect( function (player, handlepos, mousepos) |
29 | FireBlaze(player, handlepos, mousepos) |
I don't get any errors, but it doesn't work as it's supposed to since the part just spawns at a random point on the map. Did I use the parameters wrong here, or is it something else?