Hello, I am trying to send a CFrame to a RemoteEvent I have created (Shown below). This CFrame comes from a LocalScript that is in the StarterPlayerScripts section of the Explorer (This will also be shown below). The CFrame comes from the location of the player’s cursor and is sent as an argument to the RemoteEvent.
The LocalScript code:
local RS = game:GetService("RunService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local UIS = game:GetService("UserInputService")
local function GetCframe() --function to get the CFrame
local CoordX = Mouse.Hit.X
local CoordY = Mouse.Hit.Y
local CoordZ = Mouse.Hit.Z
local LookPos = CFrame.new(CoordX, CoordY, CoordZ)
return LookPos
end
Debounce = false
UIS.InputBegan:Connect(function(input) --function that takes user input and activates the RemoteEvent
if Debounce == false then
if input.KeyCode == Enum.KeyCode.E then
Debounce = true
local Coords = GetCframe()
game.ReplicatedStorage.GrappleEvent:FireServer(Coords)
task.wait(5)
Debounce = false
end
end
end)
The RemoteEvent code:
local GrappleEvent = Instance.new("RemoteEvent", game.ReplicatedStorage)
GrappleEvent.Name = "GrappleEvent"
GrappleEvent.OnServerEvent:Connect(function(TargetCoords) --the RemoteEvent that takes the argument
print(TargetCoords)
end)
My main issue is that the event always returns the CFrame data as the username of the player who the RemoteEvent is activating for instead of the respective values (Refer to the image below).
I have yet to find a solution to this problem and have tried multiple things:
- Using the GetCFrame function to return the Coords directly into the argument
- Using a variable to pass the argument
and any variations of these that I could think of.
If any body has an idea/solution, it would be greatly appreciated if you could share it here.