Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua Roblox-FE零件创建者脚本不工作_Lua_Filtering_Roblox - Fatal编程技术网

Lua Roblox-FE零件创建者脚本不工作

Lua Roblox-FE零件创建者脚本不工作,lua,filtering,roblox,Lua,Filtering,Roblox,我正在用Roblox做一个FE游戏,我在工具中的FE代码有问题。我能得到帮助吗 在工具内部: script.Parent.Activated:Connect(function() game:GetService("ReplicatedStorage"):FindFirstChild('TS'):FireServer(game.Players.LocalPlayer) end) 在事件脚本内部 local eventplace = game:GetService("ReplicatedStora

我正在用Roblox做一个FE游戏,我在工具中的FE代码有问题。我能得到帮助吗

在工具内部:

script.Parent.Activated:Connect(function()
game:GetService("ReplicatedStorage"):FindFirstChild('TS'):FireServer(game.Players.LocalPlayer)
end)
在事件脚本内部

local eventplace = game:GetService("ReplicatedStorage")
eventplace:FindFirstChild('TS').OnServerEvent:connect(function(player)
local rangeball = Instance.new('Part',workspace)
    local rangemesh = Instance.new("SpecialMesh",rangeball)
    rangemesh.MeshType = Enum.MeshType.Sphere
    rangeball.Size = Vector3.new(7,7,7)
    player.Character.Humanoid.WalkSpeed = 0
    rangeball.Parent = workspace
end)
您以前在ReplicatedStorage中创建过远程“TS”吗

还有一件事:

使用:FireServer()时,将自动传递player/client参数,因此无需执行:FireServer(game.Players.LocalPlayer),因为远程事件将接收两个参数,都是客户机/播放器

工具中使用的脚本是LocalScript。您应该改为使用非局部变量(或脚本)

而且

当您在本地脚本中使用game.Players.LocalPlayer时,攻击者可以在本地更改game.Players的名称,这将破坏您的脚本

要解决这个问题,您需要变量

在工具脚本中:

local tool = script.Parent;

tool.Activated:connect(function();
    local rangeball = Instance.new("Part", workspace); -- Since you put ', workspace' the Part will automatically be child of the Workspace. If you did Instance.new("Part", workspace.idk) it will set the parent of the part to workspace.idk, and if workspace.idk doens't exist, it will throw out a error.
    rangeball.Shape = "Sphere"; -- We can just use 'Shape' property to replace sphere meshes!
    -- No need to do 'rangeball.Parent = workspace' because with simply doing 'Instance.new("Part", workspace)' you do the same function because Instance.new takes two arguments (class, parent)!
    pcall(function() -- We use 'pcall()' here to prevent errors.
        tool.Parent.Humanoid.WalkSpeed = 0; -- Set the Player's WalkSpeed.
    end);
end);
使用该代码,您可以自由删除事件脚本

如果要使用事件,请确保事件脚本位于ServerScriptService内部,这样会更安全并正确运行。请记住,脚本仅在ReplicatedFirst、ServerScriptService、Workspace和其他一些环境中运行

希望我的回答能帮助你


还有,最后一件事,欢迎来到stack overflow

提供更多信息(详细错误消息等)。你需要尽可能彻底。我没有收到任何错误消息,代码什么也没做