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:
local tool = script.Parent local handle = tool:WaitForChild("Handle") local RS = game:GetService("ReplicatedStorage") local FlameEvent = RS:WaitForChild("FlameThrowEvent") local player = game.Players.LocalPlayer local Mouse = player:GetMouse() local handlepos = handle.CFrame.p local mousepos = Mouse.hit.p local debounce = false tool.Activated:connect(function() if debounce == false then debounce = true FlameEvent:FireServer(handlepos, mousepos) wait(2) debounce = false end end)
Server Script:
local RS = game:GetService("ReplicatedStorage") local FireEvent = RS:WaitForChild("FlameThrowEvent") local DebrisFolder = Instance.new("Folder") DebrisFolder.Parent = game.Workspace function FireBlaze(player, start, finish) local ray = Ray.new(start, (finish - start).unit * 300) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) local flame = Instance.new("Part") flame.Transparency = 0.5 flame.Anchored = true flame.CanCollide = false flame.Locked = true local distance = (start - position).magnitude flame.Size = Vector3.new(4, 4, distance) flame.CFrame = CFrame.new(start, position) * CFrame.new(0, 0, -distance/2) flame.Parent = game.Workspace game:GetService("Debris"):AddItem(flame, .5) end FireEvent.OnServerEvent:connect(function(player, handlepos, mousepos) FireBlaze(player, handlepos, mousepos) end)
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?