i get error unable to cast value to object cuz i need to refrence a player object but i have no idea what code to put in to make it do that

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Team = game:GetService("Teams"):WaitForChild("Construction")
local GetAndGivePlayerName = ReplicatedStorage:WaitForChild("GetAndGivePlayerName")
local playerName = script.Parent.RecentClickPlayerName
local player = Players:FindFirstChild(playerName.Value)

local GiveTeamName = ReplicatedStorage:WaitForChild("GiveTeamName")
print('player who clicked is ' .. playerName.Value)
wait(0.1)
GetAndGivePlayerName:FireClient(playerName.Value)
wait(0.1)
local function onGavenTeamName(playersTeam)
	if script.run.Value == true then
		if playersTeam == Team then
			print(playersTeam)
			print("player is on construction")
			script.Parent.broken.Value = false
		else
			print("player is not on construction")
			script.Parent.DisableEnableScript.runDisable.Value = true
			script.Parent.DisableEnableScript.runEnable.Value = false
		end
	end
end



5 comments

0

also it is a server script

0

On what line is the error?

0

And where is the script?

0

Not enough context to find a solution for you. Please elaborate, provide where in the code you are experiencing the error.

0

on line 8