Hey there everyone. For the past few weeks I’ve been trying to create a gravity game, however I’ve run into a problem recently with part of my code and can’t figure it out. I’ve tried for the past 4-5 days and have looked all over the place but can’t find anything. Here’s the code:
local GravityResetParts = workspace.GravityResetParts
for i, v in pairs(GravityResetParts:GetChildren()) do
print(v.Name)
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent == character then
if hit.Parent.ResetG.Value == true then
character.Humanoid.JumpPower = 50
workspace.Gravity = 196.2
hit.Parent.ResetG.Value = false
wait(2)
v.Parent = nil
hit.Parent.ResetG.Value = true
print("Reset g value")
end
end
end)
end
The variable GravityResetParts is referring to a model in the workspace with all the parts that are supposed to reset the gravity when a player touches it. This is all in a local script. I’m pretty sure changes to physics automatically replicate to the server. The problem here is that the ResetGValue, located in the character, doesn’t always return back to true after 2 seconds. It does sometimes, but not all the time. This causes the player to continually float, and since I have death parts in the game, they end up floating straight into the death parts. I’m wondering if it has something to do with the for loop, but I’m not sure what other way I could go through a model.
If anyone needs anymore clarification on what it does, or more code, then please tell me because this has been a problem for such a long time and if I can’t get it fixed, it’ll ruin my game. Thanks.