so im trying to make a tower placement system for my tower defense game. but when firing a remote event when the mouse is clicked so that the tower appears on both client and server, i keep getting the error:
Attempt to index nil with 'Transparency'
i dont really understand what it means.
here is the code on the client (also the full script is much bigger but this is the part where it fires the remote event):
Mouse.Button1Down:Connect(function()
if Mouse.Target == workspace.Placeable then
if currentdecoy == nil then
else
game.ReplicatedStorage.SpawnTower:FireServer(currentdecoy,game.ReplicatedStorage.Towers.Tower)
currentdecoy = nil
isSpawining = false
end
end
end)
here is the code on the server:
local event = game.ReplicatedStorage:WaitForChild("SpawnTower")
event.OnServerEvent:Connect(function(player,currentdecoy,tower)
print(player.Name.. " has spawned a tower")
currentdecoy.Transparency = 0
end)
do remote function instead of remote event as remote event, right after you fired the event the current decoy becomes nil so you indexed nil with transparency
bruh u should have told me that
the server cant see whats in the client
just do currentdecoy.Transparency = 1 in client script u dont need a remote event