Why I can’t get the argument in server side when fire from the client. Here is the script:
[LOCAL SCRIPT]
local function AddTowerPlaceholder(name)
IS_VIEWING_TOWER_PLACEMENT = true
local newTower = towers:FindFirstChild(name):FindFirstChild(DEFAULT_LEVEL):Clone()
newTower.Parent = workspace.Towers
for _, object in pairs(newTower:GetDescendants()) do
if object:IsA("BasePart") then
PhyscisService:SetPartCollisionGroup(object, "Towers")
end
end
local result = MouseRaycast(newTower)
newTower:PivotTo(CFrame.new(result.Position.X, result.Position.Y + newTower.Humanoid:GetAttribute("HipHeight") + (newTower.PrimaryPart.Size.Y/2), result.Position.Z) * CFrame.Angles(0, ROTATION,0))
local connection
connection = RunService.RenderStepped:Connect(function()
if IS_VIEWING_TOWER_PLACEMENT then
TOWER_TO_SPAWN = newTower
local result = MouseRaycast(newTower)
if result and result.Position then
local x = result.Position.X
local y = result.Position.Y + newTower.Humanoid:GetAttribute("HipHeight") + (newTower.PrimaryPart.Size.Y/ 2)
local z = result.Position.Z
local cframe = CFrame.new(x,y,z)
TweenService:Create(newTower.PrimaryPart, TweenInfo.new(0.035, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = cframe * CFrame.Angles(0, ROTATION,0)}):Play()
end
else
connection:Disconnect()
end
end)
end
gui.SpawnTower.MouseButton1Click:Connect(function()
if IS_VIEWING_TOWER_PLACEMENT then
return
end
AddTowerPlaceholder("Scout")
end)
UserInputService.InputBegan:Connect(function(input, processed)
if processed then
return
end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if IS_VIEWING_TOWER_PLACEMENT then
placeTowerEvent:FireServer(TOWER_TO_SPAWN)
TOWER_TO_SPAWN = nil
IS_VIEWING_TOWER_PLACEMENT = false
end
elseif input.KeyCode == Enum.KeyCode.R then
ROTATION += 90
elseif input.KeyCode == Enum.KeyCode.Q then
if IS_VIEWING_TOWER_PLACEMENT then
IS_VIEWING_TOWER_PLACEMENT = false
TOWER_TO_SPAWN:Destroy()
end
end
end)
[SERVER SCRIPT]
function towers.Spawn(tower)
tower.Parent = workspace.Towers
end
placeTowerEvent.OnServerEvent:Connect(function(player, tower)
print(player, tower)
towers.Spawn(tower)
end)
I tried printing the tower.
In Client side : “Level 1”
In Server Side : “Daptotor_Ark, nil”
If it is not clear, you can tell me and I will give you more informations.
Thank you!