Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

how do i get a player object?

Asked by 3 years ago

i get error unable to cast value to object cuz i need to reference a player object but i have no idea what code to put in to make it do that also the error is at line 11

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

1 answer

Log in to vote
0
Answered by
Ludzik78 136
3 years ago

FireClient:() Doesnt ask for the player name but asks for the player itself. Try that if you can.

Ad

Answer this question