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