Status is not a valid member of Player "Players.Phelixadmon"

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Access the “Status” folder in cloned instance rather than the player.

  2. What is the issue? Include screenshots / videos if possible!
    The game thinks I am referring to the player but I am not.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Adding an if command to ignore if the variable is the player but got hit with a warn along wit the error.

Lines responsible are the error.

function Tower.Attack(newTower)
	print(newTower, "in Tower.Attack.")
	local Config = newTower.Status
	local target = FindNearestTarget(newTower, Config.Range.Value)
	if target and target:FindFirstChild("Humanoid") and target.Humanoid.Health > 0 then
		local targetCFrame = CFrame.lookAt(newTower.HumanoidRootPart.Position, target.PrimaryPart.Position)
		newTower.HumanoidRootPart.BodyGyro.CFrame = targetCFrame
		--if Config.Damage.Value >= target.Humanoid.Health then
			--player.Cash.Value += target.Humanoid.Health
		--else
			--player.Cash.Value += Config.Damage.Value
		--end
		target.Humanoid:TakeDamage(Config.Damage.Value)
		task.wait(Config.FireRate.Value)
	end
	task.wait(0.1)
	Tower.Attack(newTower)
end

function Tower.Spawn(name, cframe)
	local towerExist = RepStorage.Towers:FindFirstChild(name)
	if towerExist then
		local newTower = towerExist:Clone()
		newTower:SetPrimaryPartCFrame(cframe)
		newTower.Parent = workspace.Towers
		newTower.HumanoidRootPart:SetNetworkOwner(nil)
		
		local bodyGyro = Instance.new("BodyGyro")
		bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
		bodyGyro.D = 0
		bodyGyro.CFrame = newTower.HumanoidRootPart.CFrame
		bodyGyro.Parent = newTower.HumanoidRootPart
		
		for i, object in ipairs(newTower:GetDescendants()) do
			if object:IsA("BasePart") then
				object.CollisionGroup = "Tower"
			end
		end
		print(newTower, "in Tower.Spawn.")
		coroutine.wrap(Tower.Attack)(newTower)
		else
		warn("Requested tower does not exist", name)
	end
end

SpawnTowerEvent.OnServerEvent:Connect(Tower.Spawn)

The output.

newTower must be not what you think it is. Try printing it out.


It printed the player’s name.

The error has to do with the script called Script, clearly, because that’s where you’re calling the function from.

The function’s information input have been changed but the warn still exist.

What did you change it too? Can you send the script?

local RepStorage = game:GetService("ReplicatedStorage")
local Tower = require(RepStorage.Tower)
local Event = RepStorage:WaitForChild("Events")
local TowerEvent = Event:WaitForChild("SpawnTower")

local function SpawnTower(Player, TowerName, CFramePosition)
	Tower.Attack(TowerName, CFramePosition)
end

TowerEvent.OnServerEvent:Connect(SpawnTower)

Here it is.

I notice this is a remote event you’re using. I think I know the problem here. One thing about remote events, the first parameters when receiving them through the server is always the player firing them. Could you send the local script meant to fire TowerEvent?

You want to access the “Status” folder in the cloned instance of the tower, rather than the player, to control the behavior of the tower’s attack.

The issue is that the code is mistakenly accessing the player instead of the cloned tower instance. The solution you tried was to add an “if” command to ignore the player, but it resulted in a warning along with the error.

To solve the issue, you need to modify the code to correctly access the “Status” folder in the cloned tower instance. This can be done by modifying the reference to “Config” in the “Tower.Attack” function to use the “newTower” parameter, which is the cloned tower instance, instead of the player.

try this:

function Tower.Attack(newTower)
print(newTower, "in Tower.Attack.")
local Config = newTower.Status
local target = FindNearestTarget(newTower, Config.Range.Value)
if target and target:FindFirstChild("Humanoid") and target.Humanoid.Health > 0 then
local targetCFrame = CFrame.lookAt(newTower.HumanoidRootPart.Position, target.PrimaryPart.Position)
newTower.HumanoidRootPart.BodyGyro.CFrame = targetCFrame
target.Humanoid:TakeDamage(Config.Damage.Value)
task.wait(Config.FireRate.Value)
end
task.wait(0.1)
Tower.Attack(newTower)
end