English 中文(简体)
无法在工作空间找到部件的服务器
原标题:Server script unable to find parts in workspace
  • 时间:2024-01-20 15:39:27
  •  标签:
  • roblox

I m 进行PvP游戏,并具备火球能力。 然而,我试图在火球触及人体毒素后摧毁该球,但该片无法在工作空间找到火球部分,并发出无限的产量警告。

这是制造火球物体的法典:

if Input.KeyCode == Enum.KeyCode.Q  then
    if debounce == true then return end
    debounce = true
    local player = game.Players.LocalPlayer
    local lookdirection = player.Character.HumanoidRootPart.CFrame.LookVector
    
    
    
    print(player, "uses Fireball")
    local fireball = game.ReplicatedStorage.Animations.FireBall.Fireball:Clone()
    fireball.Parent = workspace.Temp
    fireball.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-2)
    fireball.AssemblyLinearVelocity = lookdirection * 50
    fireball:SetAttribute("Owner", player.Name)
    
    local Force = Instance.new("BodyForce")

    Force.Force = Vector3.new(0, workspace.Gravity * fireball:GetMass() , 0)
    Force.Parent = fireball
    
    game.ReplicatedStorage.FireBall:FireServer(fireball.Size, fireball.CFrame, fireball.AssemblyLinearVelocity)
    
    wait(cooldown)
    debounce = false
    
end

参与者在宣传Q时,打着部分的手铐,将其放入工作空间。 当时,该机向“大战”扫射。

这里是《遥控法》:

game.ReplicatedStorage.FireBall.OnServerEvent:Connect(function(player)
    
    local fireball = game.Workspace.Temp:WaitForChild("Fireball")
    local hitbox = Instance.new("Part")
    hitbox.Parent = workspace.Hitboxes
    hitbox.Anchored = false
    hitbox.CanCollide = false
    hitbox.Transparency = 0.5
    hitbox.Size = fireball.Size
    hitbox.CFrame = fireball.CFram
    hitbox.AssemblyLinearVelocity = fireball.AssemblyLinearVelocity
    local Force = Instance.new("BodyForce")

    Force.Force = Vector3.new(0, workspace.Gravity * hitbox:GetMass() , 0)
    Force.Parent = hitbox
    

    --workspace.Temp:WaitForChild("Fireball").CFrame
    game.Debris:AddItem(hitbox, 2)

    local Hits = {}
    hitbox.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= player.Name then
            if Hits[hit.Parent.Name] then
                return
            end

            if hit.Parent:GetAttribute("Block")  then
                print(hit.Parent.Name, "blocks the attack")
            else

                print(hit.parent.Name, ("HIT BY FIREBALL"))
                hit.Parent.Humanoid:TakeDamage(10)

            end

            Hits[hit.Parent.Name] = true
            hitbox:Destroy()
            fireball:Destroy()
            
            wait(4)
        end
    end)

end)

I tried to pass the fireball object itself into the RemoteEvent however, I couldn t get that to work and couldn t find a direct answer on if it was possible online, So instead I have the WaitForChild method looking for the object within workspace but as said before, it just returns an infinite yield. I can see the fireball object in the folder when in-game and I m positive the spelling is correct so I m a bit clueless atm. Any help is appreciated.

最佳回答

之所以不这样做,是因为你正在向客户制造火球,然后在服务器上试图从翻车上打火。 这样做不会奏效,因为,如果你在客户上树立榜样,就不会复制服务器。

由于该部分原封不动地复制了WaitForChild,肯定会是的。

你们不能给客户制造火球,而是应该叫遥控,然后服务器应当制造火球。

附加说明的是,只要在客户和服务器上复制,你就可以通过远距离环境。

问题回答

暂无回答




相关问题
Lua-边远 不采取行动

我正试图从一个工具中发射一台遥控器,并收到服务器成像机,但在发射时,我获得“Mine不是复制后Storage”的有效成员......。

Making an AI - How to make path finding?

Hey, I am making an AI on ROBLOX and I can t seem to figure out where to start for path finding, the most common AI feature. Can anyone help? P.S. I don t know any raycasting, so I can t use that as ...

How do I program frames?

Like if i click on a fridge door and it opens, or click on a chest and the top slides off.

How do I CFrame parts?

I ve heard that you can tilt a part by a precise amount using the .CFrame property. However, I m unclear on how to use it. The following code does not work: Workspace.Part.CFrame = CFrame.new(90,0,45)...

热门标签