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

Unable to cast value to Object?

Asked by 6 years ago
Edited 6 years ago

im trying to make a filtering enabled face changer gui.

I have these 2 scripts, ServerScriptService and the Server Script in the gui

****the error is on line 7 in the server script in the gui

ServerScriptService:

game.ReplicatedStorage:WaitForChild('Faces').OnServerEvent:connect(function(player,realface)
    print("asd")
    player:WaitForChild('Character').Head.face.Texture = realface
end)

Server script in the gui:

    local f = script.Parent:GetChildren()
    for i = 1,#f do
        local face = f[i]
        if face.Name == "Face" or face.Name == "Face1" or face.Name == "Face2" then
            face.MouseButton1Down:connect(function(player)
                local realface = face.Image
                game.ReplicatedStorage:WaitForChild('Faces'):FireClient(realface)
            end)
        end
    end
0
if your game have filtering enabled you should use a RemoteEvent xJathur95x 129 — 6y
0
Im using a remote event. User#19328 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Well, you can't fire a RemoteEvent with a server using FireClient Change the serverscript in your GUI to a LocalScript and put this code.

local f = script.Parent:GetChildren()
for i = 1,#f do
    local face = f[i]
    if face.Name == "Face" or face.Name == "Face1" or face.Name == "Face2" then
    if not face:IsA("LocalScript") then
        face.MouseButton1Down:connect(function(player)
            local realface = face.Image
            game.ReplicatedStorage:WaitForChild('Faces'):FireServer(realface)--Firing it correctly
        end)
    end
    end
end
0
Now it gives out an error saying "MouseButton1Click is not a valid member of LocalScript" User#19328 0 — 6y
0
There I edited the script GetGlobals 343 — 6y
0
Thanks! User#19328 0 — 6y
Ad

Answer this question