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

Why does this error occur and or why is my script not working?

I have a GUI, which kicks a player. When a player is kicked it will provide the reason and who kicked the player, but I get this error. In addition I'm using a RemoteFunction since local scripts cant kick players.

Anyways, I get an error "MouseButton1Down is not a valid member of workspace" why is that?

Script in workspace that contains a remotefunction:

script.RemoteFunction.OnServerInvoke = function(player)
Player = game:service'Players'.LocalPlayer
script.Parent.MouseButton1Down:connect(function()
    if script.Parent.Parent.TextBox.Text == "" then
    else
        local Reason = game.Players.LocalPlayer.PlayerGui.KickGUI.KickFrame.KickReason
        local Kicked =  game.Players.LocalPlayer.PlayerGui.KickGUI.KickFrame.WhoToKick.TextBox.Text
        game.Workspace.Players:FindFirstChild(Kicked):Kick("You have been kicked, Reaspn: "..Reason)
        print(Kicked.." was kicked by "..Player.Name.. " for "..Reason)
        end
    end)
end

Local script inside the gui:

game.Workspace.Script.RemoteFunction:InvokeServer()

1 answer

MouseButton1Down is a script for a GUI. MouseClick is the correct usage.

1 comment

0

Now i get "MouseClick is not a valid member of workspace"

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