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
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 nil
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
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
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
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
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
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
.Name and .Position
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