Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Heartbeat lags behind while in a server?

Hi. I'm trying to make a sword.

The problem I'm having is with Roblox's Heartbeat feature, as it is lagging behind while in a server. What I'm trying to do here is constantly keep the sword's handle at the player's right hand (R15) using Heartbeat to keep the position and orientation the same as the player's right hand. It works flawlessly in studio, but when I test it in an online server it only updates around 10-15 times per second. Then i got a few people join, and it only updated around 1-5 times per second. I do believe this issue is occurring on Roblox's side. This is really confusing and I would like to know if there's a solution. Thanks!

The script is located inside the sword (Single union) and the variable "player" is a textlabel in the worksapce. here it is below:

game:GetService("RunService").Heartbeat:Connect(function()
	local player = workspace.name.Text
	if workspace:FindFirstChild(""..player.."") then
		script.parent.Transparency = 0
		script.parent.Position = workspace[""..player..""].RightHand.Position
		script.parent.Orientation = workspace[""..player..""].RightHand.Orientation
	else
		script.parent.Transparency = 1
	end
end)

edited because what I asked before made absolutely no sense

3 comments

0

Line 6 has a capitalisation error.

0

I realize that i never really capitalize Parent. I started out like that and it works so it eventually grew into a habit. I'll try to cap Parent when I script.

0

Ok

1 answer

✓ Accepted answer

You could simply set the item inside of the character and weld it to the hand, or use the default Roblox tool and it's properties.

2 comments

0

You're right about that... Is there a way I could switch the weld to a different player? I cant use a tool because it messes with reflectance.

0

You could destroy the weld, then move it and create another weld.

This discussion is preserved as it was. New answers, comments, and votes are closed.