RemoteEvent not properly transferring Tuples

For some reason whenever I fire a remote event with Tuples, it leaves out crucial data on the end, for example, whenever I want the position of the user of a tools head, script.Parent.Parent.Head.Position, it will only go to script.Parent.Parent. Whenever I want the orientation, I don’t even know what it does it just isn’t anywhere near the orientation of the head.

where the RemoteEvent fires from (a localscript in a tool)

game.ReplicatedStorage.AttackEvent:FireServer(script.Parent.Parent,script.Parent.Parent.Head.Position, script.Parent.Parent.Head.Orientation)

What the data of the launcher, head position, and the orientation should go.

function Attack(Launcher, head,rotate)
	local clone = game.Lighting.AttackPart:Clone()
	clone.CFrame = head*CFrame.new(0,0,-2)
	clone.Orientation = Vector3.new (rotate)
	clone.Parent = game.Workspace
	clone.Launcher.Value = Launcher.Name
	wait(.1)
	clone:Destroy()
end
game.ReplicatedStorage.AttackEvent.OnServerEvent:Connect(Attack)

EDIT: fixed a variable I had that wouldn’t have been understood if i left it as a variable

1 Like

You are passing 3 arguments to :FireServer when the listener function is expected 2 arguments only. The Launcher argument actually points to the player object of the client that fired the remote event. Also, if this script is meant to position the AttackPart to the head, just get the head position from the server; no need to open a frontier for exploiters. Though I am not sure what the arguments are for so just leave the above information for reference.

The fixed code would be this.

local function attack(player)
    local clone = game:GetService("ServerStorage").AttackPart:Clone()
    clone.CFrame = player.Character.Head.CFrame*CFrame.new(0, 0, -2)
    clone.Orientation = player.Character.Head.Orientation -- you don't create a new Vector3, just use the head orientation
    clone.Parent = game.Workspace
    clone.Launcher.Value = player.Name
    wait(0.1)
    clone:Destroy()
end

Then from the local script just call :FireServer with no arguments

Also uhh just a few nitpicks nothing too big

  • Don’t use lighting as storage. Lighting never was and never will be intended for storage. Instead, use the proper services intended for this, them being ReplicatedStorage, ServerStorage.
  • Tuples don’t exist in Lua. But they do in Python :wink:

thank you, the only issue with that is if I use the server to find the position there is a bunch of not fun tool delay

also btw tuples are in roblox lua, see?

I don’t think there would be a difference between getting the position locally or from the server. The #1 rule of filtering enabled, is quite literally, never trust the client

if you look at one of my previous posts, How to fix major tool delay you will notice that finding the position on server side is no fun

Which is why you move the part on the client + on the server. You do it on the client for immediate feedback. There will be no difference then.

I’m confused, could you direct me towards a devhub article to do that?

Just move your part on the client as well as on the server. You can even give network ownership of the part to the client and you might be able to ditch the remote completely.

I still would wish to know why the RemoteEvent is leaving out large amounts of data, when I ask it to print head (which is the head’s position in my script) it prints Johnnyfireball123 so when I ask for it’s position it gives me an error message of ServerScriptService.ProjectileScript:3: bad argument #1 (CFrame expected, got Object)

Don’t give this much trust to the client.
In your game.ReplicatedStorage.AttackEvent.OnServerEvent:Connect(Attack) your first argument is “launcher” but in an event the player always comes first, when you add the player you can get the character from the player and get the head, tool and rotation.

If you’re looking to send something back to the client when this gets fired I recommend using a RemoteFunction instead of an event (you still get player as the first argument).

1 Like