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

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

Asked by
262187 45
9 years ago

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

Log in to vote
0
Answered by 9 years ago

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

0
Now i get "MouseClick is not a valid member of workspace" 262187 45 — 9y
Ad

Answer this question