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

Why does my kick gui only detect my name and not others?

Asked by 5 years ago
Edited 5 years ago

My kick gui only seems to detect my name and not others. I really don't know why nor how to fix it, I'd be really happy if somebody could help me.

Here's the script:

local Button = script.Parent
local ButtonF = Button.Parent
local TextBox = script.Parent.Parent.Parent.KickFrame.KickText
local StarterGUI = game.StarterGui
local GPalyer = game.Players.LocalPlayer
local DebOuncer = false
local Reason = script.Parent.Parent.Parent.ReasonsFrame.ReasonText
--=====--
--Tween--
local TweenS = game:GetService("TweenService")

local TInfo1 = TweenInfo.new(9.99,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0)
local TInfo2 = TweenInfo.new(0.15,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,true,0)

---------
--=====--

Button.MouseButton1Click:Connect(function()
    if DebOuncer == false then
        DebOuncer = true
        for _,PlayerToKick in pairs(game:WaitForChild("Players"):GetPlayers()) do
            if PlayerToKick.Name == TextBox.Text then
                PlayerToKick:Kick(Reason.Text)
                print(PlayerToKick.Name..' was kicked')
                TextBox.Text = PlayerToKick.Name..' has been kicked'
                TweenS:Create(TextBox, TInfo2, {TextColor3 = Color3.fromRGB(157,255,66)}):Play()


            else
                TweenS:Create(TextBox, TInfo2, {TextColor3 = Color3.fromRGB(255,30,0)}):Play()
                TextBox.Text = 'Player was not found or Player was already kicked'
                warn('Name does not exist')
            end
        wait(.1)
        end

ButtonF.ImageColor3 = Color3.fromRGB(255,0,0)
TweenS:Create(ButtonF, TInfo1, {ImageColor3 = Color3.fromRGB(80,179,255)}):Play()
    wait(9.99)
    DebOuncer = false
    end
end)

The script is located in a "LocalScript" and it activates once the player click the "Kick Button"

0
The script seems to only kick one person at a time. When you enter their name, it is case sensitive. Shawnyg 4330 — 5y
0
This might be happening because you aren't firing any RemoteEvents to kick the player from the server, so the LocalScript is probably detecting the other players, but everything happening is only client sided. AnonymouseCow 23 — 5y
0
Are there any errors? AnonymouseCow 23 — 5y

2 answers

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

EDITED: Removed RemoteEvents Stuff!

Sorry! I had an enormous brain fart, you should use RemoteFunctions, not RemoteEvents. You can transmit data on the player through remote functions. Try something a little like this:

-----On the ServerScript you can try this to kick the player----

        local remoteFunction = Instance.new("RemoteFunction")
    remoteFunction.Name = "kickfunction"
    remoteFunction.Parent = game.ReplicatedStorage

    remoteFunction.OnServerInvoke = function(client,args)
        local PlayerToKick = args.PlayerToKick
        PlayerToKick = game.Players:FindFirstChild(PlayerToKick)

        if PlayerToKick then
            PlayerToKick:Kick("INSERT REASON HERE")
        end
        end

----On the LocalScript you can do this to detect the player given in the text box----


            Button.MouseButton1Click:Connect(function()
                for _,PlayerToKick in pairs(game:WaitForChild("Players"):GetPlayers()) do

            if PlayerToKick.Name == TextBox.Text then



            local plr = PlayerToKick.Name
                local info = {PlayerToKick = plr}
                local result = game.ReplicatedStorage.kickfunction:InvokeServer(info)
                print(result)

            end
            end
            end)


For more information on RemoteFunctions read the REMOTEFUNCTIONS section of this article RemoteFunctions (My head hurts now.)

0
But how should I fire the event? FireClient(), FireAllClients() or FireServer()? MeshyOryx 2 — 5y
0
You should fire the event with FireServer(). FireClient() and FireAllClients() are used in server scripts to fire a RemoteEvent and communicate with LocalScripts. AnonymouseCow 23 — 5y
0
I did the remote event but I can still only kick myself MeshyOryx 2 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

I tried this but yet still only kicks me...

Local kick button script:

local Button = script.Parent
local ButtonF = Button.Parent
local TextBox = script.Parent.Parent.Parent.KickFrame.KickText
local StarterGUI = game.StarterGui
local GPalyer = game.Players.LocalPlayer
local DebOuncer = false
local Reason = script.Parent.Parent.Parent.ReasonsFrame.ReasonText
local KickEvent = game.ReplicatedStorage.EventsForKick
--=====--
--Tween--
local TweenS = game:GetService("TweenService")

local TInfo1 = TweenInfo.new(9.99,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0)
local TInfo2 = TweenInfo.new(0.15,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,true,0)

---------
--=====--

Button.MouseButton1Click:Connect(function()
    if DebOuncer == false then
        DebOuncer = true
        for _,PlayerToKick in pairs(game:WaitForChild("Players"):GetPlayers()) do
            if PlayerToKick.Name == TextBox.Text then
                KickEvent.KickEvent:FireServer(PlayerToKick)
-------             =PlayerToKick:Kick(Reason.Text)=
                print(PlayerToKick.Name..' was kicked')
                TextBox.Text = PlayerToKick.Name..' has been kicked'
                TweenS:Create(TextBox, TInfo2, {TextColor3 = Color3.fromRGB(157,255,66)}):Play()


            else
                TweenS:Create(TextBox, TInfo2, {TextColor3 = Color3.fromRGB(255,30,0)}):Play()
                TextBox.Text = 'Player was not found or Player was already kicked'
                warn('Name does not exist')
            end
        wait(.1)
        end

ButtonF.ImageColor3 = Color3.fromRGB(255,0,0)
TweenS:Create(ButtonF, TInfo1, {ImageColor3 = Color3.fromRGB(80,179,255)}):Play()
    wait(9.99)
    DebOuncer = false
    end
end)





Fired event script:


local KickEventThing = game.ReplicatedStorage.EventsForKick KickEventThing.KickEvent.OnServerEvent:Connect(function(PlayerToKick) PlayerToKick:Kick() print('Kick was a succes') end)
0
Okay, I edited my answer! You DON'T used remoteevents for things like this, you use RemoteFunctions! AnonymouseCow 23 — 5y

Answer this question