So, I’m trying to make a code that “jiggles” rocks around when the rocks are hit. But for whatever reason, it isn’t properly resetting the rocks cframe to its original location (Making the rocks slowly move around as they get hit)
I’ve made sure no rocks are being effected twice, or anything like that. Any ideas?
for _,rock in pairs(rocksHit) do
coroutine.wrap(function()
local cf = rock.PrimaryPart.CFrame
for i = 1,6 do
rock:SetPrimaryPartCFrame(cf * CFrame.new(RNG:NextNumber(-0.3,0.3),0,RNG:NextNumber(-0.3,0.3)))
task.wait()
end
rock:SetPrimaryPartCFrame(cf)
end)()
end
Are you absolutely certain? You have a working debounce set up?
Pretty certain yeah. I’ve tested with the coroutine off with a long wait in-between, made sure the same rocks can’t be put into the table twice, and even added a print(“Rock”) to see if it would print more times than the amount of rocks I hit, and still nothing.
The actual hitting of the rocks happens after a second or so, so this isn’t a rapid fire type deal
For the record, I found the problem
The hitbox to the rock (which is invisible) wasn’t actually anchored. The meshpart for the rock was. I was actually just moving the hitbox around with my character, and the meshpart model would move with it as I moved the entire model with :SetPrimaryPartCFrame
Such a silly oversight, lol