Errors making Remote fuctions with freemodel and rogue scripts

Been stuck on this for almost a week now ive studied theese rogue scripts and my freemodels, i can only get the server side tower to play but the remote function allways returns back as an error

Any info you can provide to help me move forward in the right direction would be greatly appreciated
image



CurrentSeletion is a obj value
Placing is a String value


module tower script

image

server


game.ReplicatedStorage.Events.PlaceTower.OnServerInvoke = function(player, u2, v26, u1)
	
	
	if player.playerGui.ScreenGui.CurrentSelection.Value == "" then
		player.PlayerGui.ScreenGui.Placing.Value = u2
			
	local Name = require(game.ReplicatedStorage.TowerStorage[u2.Name]).StarterStats.DisplayName
	v26 = v26.Position  -- this is obv a table but im still stuck on u2 and Name attempting to index with nil
		

	end
	end



Main Script - local script

Video of tower placing, first studio is without remote functions
2nd Studio is the one im having issues with on trying to create the remote function to place the tower

On line 662 and 663 you destroy and remove “u2”
Then on line 667 you attempt to read the “Name” property of “u2” but us2 nil.

Two approaches: Destroy “u2” after running this code, or set a variable before destroying it that has it’s name, and use that name variable on like 667.


when the invoke plays its when you do not have a current tower selected. the only way current selection is nil is if you do not have a currently placed active tower in workspace selected, to upgrade ect or see the range part. So when v103 = nil/invoked its when you want u2/u2.Name to be created Tower placed into game.workspace.Game.towers from the server scright right??

when you click the tower you want to place client side creates the hitbox and the range part and creates a copy of the tower for only the client side, i need the server side to create it so it can actually be placed into the game, but no matter how to try to refer to the tower i come back with nilimage

uploaded a video of both versions of what im trying to accomplish


Even when i destroy u2 and = it to nil i still get the same error and i do not create anything in the workspace same issue as before


game.ReplicatedStorage.Events.PlaceTower.OnServerInvoke = function(player, u2, v26, u1)
	
	
	if player.playerGui.ScreenGui.CurrentSelection.Value == "" then
		player.PlayerGui.ScreenGui.Placing.Value = u2
			
	local Name = require(game.ReplicatedStorage.TowerStorage[u2.Name]).StarterStats.DisplayName
	v26 = v26.Position  -- this is obv a table but im still stuck on u2 and Name attempting to index with nil
		local cash = player.Cash.Value
		local cost = require(game.ReplicatedStorage.TowerStorage[u2.Name].Starterstats.Price)
		if cash >= cost then 
			cash = cash - cost
								
		local tower = Instance.new("Model")
		tower.Name = player.PlayerGui.ScreenGui.Placing.Value
		tower.Position = v26
		tower.Parent = game.Workspace.Game.Towers
		
		local copyserver = game.ReplicatedStorage.TowerStorage[u2].Tower:Clone()		
		copyserver.Parent = game.Workspace.Game.Towers.tower
		
		local copyclient = game.ReplicatedStorage.TowerStorage[u2].Client:Clone()	
		copyclient.Parent = game.Workspace.Game.Towers.tower
		
		u2:Destroy()
		u2 = nil
		end
	end
	end

image

game.ReplicatedStorage.Events.PlaceTower.OnServerInvoke = function(player, u2, v26, u1)
	u2 = u2.Name
	v26 = v26.Position
	player.StarterGui.PlayerGui.Placing.Value = u2.Name
	print("Type of u2 is:", type(u2.Name))
	print("typeof() u2 is:", typeof(u2.Name))
end

no matter what the script just ignores the invoke and rejects name

if i remove Name from the invoke

	local v103 = game.ReplicatedStorage.Events.PlaceTower:InvokeServer(u2, v26.Position, u1)

image
if i remove the server script i still get

As @VitalWinter said, you literally destroy and set u2 to nil on lines 662 and 663. Of course it can’t get name.

@7z99 you can send tables using remote events, I believe it was dictionaries with different types of keys that aren’t allowed.

1 Like

v26.Position is the cursor location vector 3 of the hitbox, tower, and range so basicly your just setting the onserverevent to those values but, but regardless no matter what i define name as it allways comes back as indexed to nil so i am not able to debug anything i write in the server script

image
the destroy is if someone tries to place a tower on a part in the not placable folder

If it’s for someone trying to place an invalid object, why are you still invoking the server?

like i showed in the video client side you have a tower, range/part, a hitbox, this stuff only shows for the player on client side before the tower is created, to make sure you do not place them in the same location as another tower or in a not placable area

image

on the invoke you need to place the actual tower range/part, and hitbox , that creates the tower inside the workspace so it can interact with the game. but i can not do this because everything i try to put in the server script will not recognize Name or any value given to it


somebody wrote this out there somewhere and it works and it functions together an i have no way to find a example on how it works to pass information from the client to the server

https://developer.roblox.com/en-us/api-reference/callback/RemoteFunction/OnServerInvoke

https://developer.roblox.com/en-us/api-reference/function/RemoteFunction/InvokeServer

i have my self wrote from scratch a working Onserver invoke. but for some reason this is different i am not able to pass information with this involved
image
.Name and .Position

image

how do i learn about adding stuff into parameters that i never seen before

image
image
so vector3 and instance/string invoked into a server functions parameters how does it work? clearly the vector 3 doesnt need to go to the server or back because its only client side in this cause because its the based off the position of the mouse, but the name and thats were my error is coming from

after 20 hours strait working on this today i found a similar remote function in one of Alvin blox’s videos
image