I have recently got a problem where the RemoteFunction’s arguments are not ordered correctly. I am not sure why or how this is happening, Hopefully this can be solved.
Server Script
game.ReplicatedStorage.PlaceFunc.OnServerInvoke = function(Target, TargetSurface, selection, side)
local AddedPart = Target:Clone()
print(TargetSurface) -- Target (Wrong)
print(Target) -- Player (Wrong)
print(selection) -- Part (Correct)
print(side) -- Side (Correct)
print(AddedPart) -- nil (Wrong)
AddedPart.Parent = workspace
local blacklist = {
game.Workspace.Baseplate
}
for i, v in pairs(blacklist) do
if v == selection.Adornee then
selection.Adornee = nil
end
end
if selection.Adornee == Target then
if side == "Top" then
AddedPart.CFrame = Target.CFrame + Vector3.new(0, Target.Size.Y/2 + AddedPart.Size.Y/2, 0)
elseif side == "Bottom" then
AddedPart.CFrame = Target.CFrame + Vector3.new(0, -Target.Size.Y/2 - AddedPart.Size.Y/2, 0)
end
end
end
game.ReplicatedStorage.PlaceFunc.OnServerInvoke = function(Player, Target, TargetSurface, selection, side)
local AddedPart = Target:Clone()
print(Player) -- Player
print(Target) -- Player
print(TargetSurface) -- Part
print(selection) -- Enum.NormalId.Top
print(side) -- Part
print(AddedPart) nil
AddedPart.Parent = workspace
local blacklist = {
game.Workspace.Baseplate
}
for i, v in pairs(blacklist) do
if v == selection.Adornee then
selection.Adornee = nil
end
end
if selection.Adornee == Target then
if side == "Top" then
AddedPart.CFrame = Target.CFrame + Vector3.new(0, Target.Size.Y/2 + AddedPart.Size.Y/2, 0)
elseif side == "Bottom" then
AddedPart.CFrame = Target.CFrame + Vector3.new(0, -Target.Size.Y/2 - AddedPart.Size.Y/2, 0)
end
end
end
It might be better (and cleaner) to send your parameters inside a dictionary. The function shouldn’t be changing the order of these parameters, unless there’s something wrong with your code somewhere else.