Roblox Kick Argument 1失踪 [英] Roblox Kick Argument 1 missing

查看:69
本文介绍了Roblox Kick Argument 1失踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我输入用户名,然后键入原因,然后使用以下脚本按kick时,我总是会丢失参数1:

i keep getting missing argument 1 when i type my username then type reason then press kick using these scripts below:

本地

local Replicated = game:GetService("ReplicatedStorage")
local reason = script.Parent.Parent.Reason
local player = script.Parent.Parent.Name

script.Parent.MouseButton1Click:Connect(function()
    Replicated.Events.Kick:FireServer(player.Text, reason.Text)
end)

服务器

local KickPlayer = game.ReplicatedStorage.Events.Kick

KickPlayer.OnServerEvent:Connect(function(Name,Reason)
    game.Players:FindFirstChild(Name):Kick(Reason)
end)

这将起作用,但其他人则不会

this will work but not the otherone

KickPlayer.OnServerEvent:Connect(function(Name,Reason)
    game.Players:FindFirstChild("username"):Kick(Reason)
end)

这给出ServerScriptService.Event_Handler:14:尝试用'Kick'索引nil

this gives ServerScriptService.Event_Handler:14: attempt to index nil with 'Kick'

KickPlayer.OnServerEvent:Connect(function(Player,Reason)
    game.Players:FindFirstChild(Player):Kick(Reason)
end)

推荐答案

以此替换服务器脚本

local KickPlayer = game.ReplicatedStorage.Events.Kick

KickPlayer.OnServerEvent:Connect(function(_, Name,Reason) -- "_" is the player instance
    game.Players:FindFirstChild(Name):Kick(Reason)
end)

这是"RemoteEvent.OnServerEvent"的原型

and this is the prototype of "RemoteEvent.OnServerEvent"

 RBXScriptSignal OnServerEvent ( Instance player , Tuple arguments )

这篇关于Roblox Kick Argument 1失踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆