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

hitbox on click script is delayed when the player is moving, any solution?

I know the question sounds a little vague so ill explain it fully here: I'm making a fighting game, and in order to do that I need a script where when the player clicks, a hitbox part appears where the player is standing. For some reason, when I run the script while moving, the hitbox always appears behind me instead. Its a small issue, but I really need it fixed to make this game work well. (also if you dont get what i mean, heres a gif showing what im talking about (https://gyazo.com/653233723b164cabb639a7ffde335024))

and heres the script

game.ReplicatedStorage.blahblahblah.OnServerEvent:Connect(function(player,cframe)
	
	local character = player.Character
	
	local hitbox = Instance.new("Part")
	hitbox.Size = Vector3.new(4.2, 5.1, 4.1)
	hitbox.Color = Color3.fromRGB(255, 0, 0)
	hitbox.Transparency = 0.6
	hitbox.CanCollide = false
	hitbox.Anchored = true
	hitbox.CFrame = character.HumanoidRootPart.CFrame
	
	hitbox.Parent = character
end)

also if you're wondering, this is running on a remote event

1 answer

You could try looping the hitboxes position for a certain amount of time:

function WaitTime()

local T = 0

repeat 
hitbox.CFrame = character.HumanoidRootPart.CFrame
T = T+1
wait(0)
until T == 5

end

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