how exactly are you rotating the part
I’m tried to spectate on player from server side, yes it actually has delay on client side, but I can’t get it why? and how to fix it?
with CylindricalConstraint, no scripts
ok, this is a wild guess, but maybe the client owns the part instead of the server. in the for loop, make sure the part has its network ownership set to nil to make it server sided
i.e:
local char = script.Parent -- this is fine
local hum = char:FindFirstChild("Humanoid")
local parts = workspace:GetChildren() -- or wherever your killparts are
local db = false
for _, part in pairs(parts) do
if part.Name == "damagePart" or part.Name == "killPart" then
part:SetNetworkOwner(nil)
end
part.Touched:Connect(function(hit)
if hit.Parent ~= char then return nil end
if part.Name == "damagePart" then
if db == true then return nil end
db = true
hum.Health -= 5
wait(1)
db = false
elseif part.Name == "killPart" then
hum.Health = 0
end
end)
end
actually you cant do that from the client, so do that in a server script
alright, so if the part is anchored then it is automatically on the server so thats not the issue.
give me a few minute to recreate your setup in a game, ill get back to you
What is the spinning script? Could you please provide it?
now i cant be sure, but it might be linked to that constraint.
roblox constraints arnt very… good. or stable
what i would recommend is changing the parts cframe every millisecond
while wait(.1) do
script.Parent.CFrame *= CFrame.Angles(0,math.rad(1),0)
end
now you can change the 1 to the value of your choice, higher the faster.
im not certain that this is the problem, but it could be.
local runService = game:GetService("RunService")
local damageRange = 5 -- Distance within which damage is applied
local debounceTime = 1 -- Cooldown time in seconds
local debounces = {} -- Table to track debounces for each player
local humanoid = script.Parent:FindFirstChild("Humanoid")
-- Ensure Humanoid exists
if not humanoid then
warn("Humanoid not found!")
return
end
-- Table to store damaging parts in the workspace
local damagingParts = {}
for _, part in pairs(workspace:GetChildren()) do
if part.Name == "damagePart" or part.Name == "killPart" then
table.insert(damagingParts, part)
end
end
-- Coroutine function for applying damage
local function applyDamage(damage)
-- Debounce check
if not debounces[humanoid] then
debounces[humanoid] = true
humanoid.Health -= damage
coroutine.wrap(function()
wait(debounceTime) -- Cooldown period
debounces[humanoid] = false -- Reset debounce after cooldown
end)()
end
end
-- Function to track player part positions
local function trackPlayer()
runService.Heartbeat:Connect(function()
if humanoid.Health > 0 then
for _, bodyPart in pairs(script.Parent:GetChildren()) do
if bodyPart:IsA("BasePart") then
for _, damagePart in pairs(damagingParts) do
local distance = (damagePart.Position - bodyPart.Position).Magnitude
-- If the player is within range of a damagePart or killPart
if distance <= damageRange then
if damagePart.Name == "damagePart" then
applyDamage(5) -- Damage amount
elseif damagePart.Name == "killPart" then
print("DEBUG: KILL PART TOUCHED")
applyDamage(math.huge) -- Instant kill
end
end
end
end
end
end
end)
end
-- Start tracking the player's proximity to damaging parts
coroutine.wrap(trackPlayer)()
It would be good to introduce good programming habits.
local SpinPart = [path]
local SpinSpeed = 5 -- How much to increment per 0.1 seconds
SpinSpeed = math.rad(SpinSpeed) -- Converts to radians (X / 180)
while true do
wait(0.1)
SpinPart.CFrame *= CFrame.fromEulerAngles(0, SpinSpeed, 0)
end
Unfortunately I do not have access to Studio at the moment. Can you provide the script text for the spinning brick if applicable?
that measures magintude from the center of the part, which wouldnt change with rotation.
my bad lol, i typed that out in the reply box quickly, also they are using a cylindricalconstraint for movement.
That indeed does sound finnicky. Personally I do not use constraints; instead I stick to the legacy BodyMovers. Perhaps the OP may get some benefit out of them as well? BodyMover | Documentation - Roblox Creator Hub | New Body Movers - Updates / Announcements - Developer Forum | Roblox
agreed, i hate how roblox is phasing out and depreciating them when 99% of the time they work better then their newer alternatives.
Unfortunately that’s how it goes with technology. As time goes on it gets more difficult to maintain older features. Instead of opting to go back and re-write how they work in the modern engine and potentially breaking the behavior that older games / gears relied on, they mark them as deprecated
meaning that they’re out of support and will not be updated. If they break down the line, that’s unfortunately the reality for them.
Getting back on topic, the OP could use the BodyGyro
bodymover. Since bodymovers update with the physics engine, it’s perfect to use in cases where it involves the player’s character.
BodyGyro.MaxTorque = Vector3.new(0, 9999, 0) -- Only applies force to the Y axis
BodyGyro.D = 1111
BodyGyro.P = 9999
while true do
BodyGyro.CFrame *= math.rad(0, math.pi / 4, 0) -- Rotates 45 degrees every 0.1 seconds
wait(0.1)
end
The only downside is that the part cannot be anchored with legacy bodymovers, otherwise they will not work.
You decide to use my system or not.
video demonstrating what it does https://gyazo.com/67ecc02a5f53efa758e533401378f8a7
script:
local cos = game:GetService("CollectionService")
local run = game:GetService("RunService")
local dmgBrickNme = "damage_brick"
local dmgNme = "dmg"
local cdNme = "cooldwn"
local speed = 3
for _, brick in cos:GetTagged(dmgBrickNme) do
if brick:IsA("BasePart") then
local connection = nil
local deb = false
local damage = brick:GetAttribute(dmgNme) or 20
local cooldown = brick:GetAttribute(cdNme) or .5
local function spin()
run.Stepped:Connect(function(...)
brick.CFrame *= CFrame.Angles(0, math.rad(speed), 0)
end)
end
spin()
local function touched(hit:Part)
local p = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if p and p.Health > 0 and not deb then
deb = true
p:TakeDamage(damage)
task.wait(cooldown)
deb = false
end
end
connection = brick.Touched:Connect(touched)
end
end
Check if the basepart that touched is part of a player. This also happens to me for some reason and I don’t know why, but doing that fixes the problem atleast for me.
Physics are handled on the server, so whilst .Touched ran without you actually touching the part on the client, the server detects that you have in fact touched it; from the perspective of the server. To fix this, you are going to need to render the spinning part on the client and set the spinning part’s network owner to that client. Of course, you will need to send a call to the server when the client touches the spinning part.