Hello, I am making some spheres that are rolling down a mountain, and if the player touches one of them, he dies, but since the spheres are unanchored, sometimes, it kills the player even though he is far away from the spheres.
I already tried setting the network ownership to the server, but it didn’t change anything.
Here is my script that spawns the spheres.
local serverStorage = game:GetService("ServerStorage")
local jawBreakersFolder = serverStorage:WaitForChild("JawBreakers")
local jawBreakers = jawBreakersFolder:GetChildren()
local positions = {Vector3.new(-374.414, 637.492, -1395.13), Vector3.new(-354.243, 652.146, -1352.7), Vector3.new(-432.1, 665.348, -1371.7)}
local delayTime = 1.5
while true do
local jawBreakerChosen = jawBreakers[math.random(1, #jawBreakers)]
local jawBreaker = jawBreakersFolder:WaitForChild(jawBreakerChosen.Name)
local firstjawBreaker = jawBreaker:Clone()
firstjawBreaker.Parent = script.Parent
firstjawBreaker:SetNetworkOwner(nil) -- set network ownership to server
firstjawBreaker.Position = positions[math.random(1, #positions)]
wait(delayTime)
jawBreakerChosen = jawBreakers[math.random(1, #jawBreakers)]
jawBreaker = jawBreakersFolder:WaitForChild(jawBreakerChosen.Name)
local secondjawBreaker = jawBreaker:Clone()
secondjawBreaker.Parent = script.Parent
secondjawBreaker:SetNetworkOwner(nil) -- set network ownership to server
secondjawBreaker.Position = positions[math.random(1, #positions)]
wait(delayTime)
end
This is the script that kills the player
script.Parent.Touched:Connect(function(hit)
local partParent = hit.Parent
local humanoid = partParent:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end)
Thanks