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

ROBLOX U Stickmasterluke's Mad Bloxxer Tutorial "Unable to cast value to Object" Not working again?

OK, so earlier I asked a question about the stickmasterluke mad bloxxer tutorial. I got help from that, fixed it, and moved on. Now there is another error saying: "12:35:53.396 - Unable to cast value to Object" and I was thinking, is it because of FiringClient?

Here is what I have for the error:

--give players tools
				local backpack = player:FindFirstChild("Backpack")
				if backpack then
					
					if player == knifeman then
						local knife = ss:WaitForChild("Knife"):clone()
						knife.Parent = backpack
						event:FireClient("Class", "Knifeman")

					elseif player == officer then
						local revolver = ss:WaitForChild("Revolver"):clone()
						revolver.Parent = backpack
						event:FireClient("Class", "Officer")
						
					else
						event:FireClient("Class", "Innocent")

so it says that error on the "event:FireClient" parts. So is it something wrong? I added varibles for serverstorage to make it ss. Anyone know the problem and how should I fix it?

1 comment

3

The first paramater of 'FireClient' must be the client or the event does not know who to sent the information to. You currently are trying to cast 'string' to a player object hence the error.

1 answer

✓ Accepted answer

Check the Wiki

A quick search on the Wiki for FireClient pulls up the API reference for RemoteEvent:FireClient, which just so happens to be the function giving you the error.

As Kingdom mentions, your Player argument is a string rather than a Player, and is therefore giving you an error. The solution is to provide a Player as the first argument so that it knows who to tell.

--give players tools
                local backpack = player:FindFirstChild("Backpack")
                if backpack then

                    if player == knifeman then
                        local knife = ss:WaitForChild("Knife"):clone()
                        knife.Parent = backpack
                        event:FireClient(player, "Class", "Knifeman")

                    elseif player == officer then
                        local revolver = ss:WaitForChild("Revolver"):clone()
                        revolver.Parent = backpack
                        event:FireClient(player, "Class", "Officer")

                    else
                        event:FireClient(player, "Class", "Innocent")

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