在ROBLOX Studio中启用过滤后客户端放置方块

我正在尝试让我的迷你游戏在启用了过滤后能正常工作(在客户端进行的放置part之类的操作不会影响服务端)。目前唯一出现问题的是一个迷你游戏。玩家放置方块来阻止由于减压而被吸入太空的游戏玩法是迷你游戏的核心。由于放置方块是在客户端完成的,所以启用了过滤后不能正常工作。我试图通过远程事件来解决这个问题,每次玩家尝试放置一个方块时都调用该事件,参数是放置的方块和其放置的CFrame。然而,每次我通过本地服务器测试时,都告诉我参数'part'是空的,尽管我确实提供了它。

这是相关脚本中与此相关的代码: 服务器脚本:

pBEvent.OnServerEvent:connect(function(player,partToPlace,position)
    partToPlace.Parent=sp.Blocks
    partToPlace.CFrame=position
    wait()
    partToPlace:MakeJoints()
    partToPlace.Anchored=false
end)

本地脚本:

m.Button1Down:connect(function()
    if m.Target and m.Target.Name == script.Parent.Parent.Name and amount.Value > 0 and db == false or m.Target.Name == "Part" and db == false and amount.Value > 0 then
        db = true
        amount.Value = amount.Value - 1
        local lastpos = drag.CFrame
        local dragc = drag:Clone()
        dragc.Anchored = true

        dragc.Name = game.Players.LocalPlayer.Name

        dragc.Transparency = 0
        dragc.ff:Destroy()
        event:FireServer(dragc,lastpos)
    end
end)
点赞
用户1305128
用户1305128

你正在向服务器传递一个名为 dragc 的克隆体,但是代码中并没有 drag。尝试克隆 m.Target:

m.Button1Down:connect(function()
    if m.Target and m.Target.Name == script.Parent.Parent.Name and amount.Value > 0 and db == false or m.Target.Name == "Part" and db == false and amount.Value > 0 then
        db = true
        amount.Value = amount.Value - 1
        local lastpos = m.Target.CFrame
        local dragc = m.Target:Clone()
        dragc.Anchored = true

        dragc.Name = game.Players.LocalPlayer.Name

        dragc.Transparency = 0
        dragc.ff:Destroy()
        event:FireServer(dragc,lastpos)
    end
 end)
2018-03-21 18:09:41