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

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

Asked by 8 years ago

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?

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. User#5423 17 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

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")
Ad

Answer this question