Hello! So, I have this code (I want the player to float for a few seconds and then go down):
Server
local RenderEvent = game:GetService("ReplicatedStorage"):WaitForChild("RenderEvent")
RenderEvent.OnServerEvent:Connect(function(plr, amplitude)
local probs = math.floor(math.random(0, 100))
if song.IsPlaying and amplitude <= 2.5 and probs == 1 and activated == false then
activated = true
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local animator = hum:WaitForChild("Animator")
local animation_floating = game:GetService("ReplicatedStorage"):WaitForChild("animations"):WaitForChild("floatings"):WaitForChild("floating_001")
local load_floating = animator:LoadAnimation(animation_floating)
load_floating:Play()
local tween_info_start = TweenInfo.new(5)
local tween_properties_start = {Position = Vector3.new(char.PrimaryPart.Position.X, char.PrimaryPart.Position.Y + 20, char.PrimaryPart.Position.Z)}
local tween_start = TweenService:Create(char.PrimaryPart, tween_info_start, tween_properties_start)
--hrp.Anchored = true
tween_start:Play()
tween_start.Completed:Wait()
--hrp.Anchored = false
--char:MoveTo(Vector3.new(char.PrimaryPart.Position.X, char.PrimaryPart.Position.Y + 20, char.PrimaryPart.Position.Z))
task.wait(20)
activated = false
if load_floating then
load_floating:Stop()
end
end
end)
The problem is that when the player is floating, the player is affected by gravity (constantly fighting with the tween), but disabling the workspace gravity is not an option, since there will be an option in the game on the client side that prevents that you can float. I tried anchoring the humanoid, but I want the player to be able to move while floating.
Notes:
- The event is emitted on each frame (RunService.RenderStepped)