I made snow deformation and accomplished it, but I have 2 problems arising from it.
When the player jumps or walks too fast, the result turns nil and breaks the whole script. Error Data: Workspace.Player1.Deform:29: attempt to index nil with 'Instance'
The deformation appears to be delayed. Error Data: N/A
Heres The Code:
while wait() do local R_Result = workspace:Raycast(RFoot.Position, RFoot.CFrame.UpVector * MaxLength, RayParams) local L_Result = workspace:Raycast(LFoot.Position, LFoot.CFrame.UpVector * MaxLength, RayParams) if R_Result and R_Result ~= nil then RAttachment.WorldPosition = R_Result.Position if R_Result.Instance then if R_Result ~= nil and R_Result.Instance.Parent:IsA("Bone") and L_Result.Instance.Parent.Parent.Name == "Snow" then game.TweenService:Create(R_Result.Instance.Parent, TweenInfo.new(dbTime), {WorldPosition = R_Result.Instance.Parent.WorldPosition - Vector3.new(0,1.5,0)}):Play() -- Error end end else RAttachment.WorldPosition = RFoot.Position + (RFoot.CFrame.UpVector * MaxLength) end if L_Result and L_Result ~= nil then LAttachment.WorldPosition = L_Result.Position if L_Result.Instance then if L_Result ~= nil and L_Result.Instance.Parent:IsA("Bone") and L_Result.Instance.Parent.Parent.Name == "Snow" then game.TweenService:Create(L_Result.Instance.Parent, TweenInfo.new(dbTime), {WorldPosition = L_Result.Instance.Parent.WorldPosition - Vector3.new(0,1.5,0)}):Play() -- Error end end else LAttachment.WorldPosition = LFoot.Position + (LFoot.CFrame.UpVector * MaxLength) end end
All help would be appreciated, I need answers quickly so I can hopefully fix this. Also when the deformation appears delayed should I use a better alternative instead of using the loop
"while wait() do"
Thank you.
I think you might be able to disable the script when jumping and limit the walk speed to however much doesn't break it. (An easier option since you don't have to do so much scripting)