Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Local script inside of your button
- local speed = 50
- repeat wait() until game.Players.LocalPlayer.Character
- local button = script.Parent.Parent.FlyButton
- local plr = game.Players.LocalPlayer
- local char = plr.Character
- local hum = char:WaitForChild("Humanoid")
- local Torso = char:WaitForChild("HumanoidRootPart")
- local Mouse = plr:GetMouse()
- local toggle = false
- -- function
- script.Parent.MouseButton1Click:Connect(function()
- if script.Parent.MouseButton1Click then
- if toggle == false then
- toggle = true
- local Anim = Instance.new("Animation")
- Anim.AnimationId = "rbxassetid://9665206880"-- Animation while flying
- local PlayAnim = hum:LoadAnimation(Anim)
- PlayAnim:Play()
- local BV = Instance.new("BodyVelocity",Torso)
- BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
- while toggle == true do
- BV.Velocity = Mouse.Hit.LookVector*speed
- wait()
- end
- end
- if toggle == true then
- toggle = false
- Torso:FindFirstChildOfClass("BodyVelocity"):Destroy()
- local tracks = hum:GetPlayingAnimationTracks()
- for i, stopTracks in pairs(tracks) do
- stopTracks:Stop()
- end
- local Anim = Instance.new("Animation")
- Anim.AnimationId = "rbxassetid://0" -- Animation while idle (I recomend to not change this)
- local PlayAnim = hum:LoadAnimation(Anim)
- PlayAnim:Play()
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement