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.