Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

cannot cast value to object?

i already asked this question and i did get an answer but i am still having trouble soo...

i am supposed too put in a player object into line 9 instead of a player name but i don't know how

2 answers

i forgot to add the code

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 GiveTeamName = ReplicatedStorage:WaitForChild("GiveTeamName")
print('player who clicked is ' .. playerName.Value)
wait(0.1)
GetAndGivePlayerName:FireClient(player)
print(playerName)
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



You never define player

Put this before the call

local plauer = Players:FindFirstChild(playerName.Value)

This discussion is preserved as it was. New answers, comments, and votes are closed.