Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TweenService = game:GetService("TweenService")
- local turntime = 1 -- Turn time in seconds
- function Use(...)
- local args = {...}
- local nearestdistance = math.huge
- local nearestplayer
- for _, i in pairs(game.Players:GetPlayers()) do
- local distancecheck = i:DistanceFromCharacter(args[1].Torso.Position)
- if distancecheck < nearestdistance then
- nearestplayer = i
- nearestdistance = distancecheck
- end
- end
- local cf = {CFrame = CFrame.lookAt(args[1].HumanoidRootPart.Position, nearestplayer.Character.Torso.Position)}
- TweenService:Create(args[1].HumanoidRootPart, TweenInfo.new(turntime), cf):Play()
- wait(turntime) -- This lets it fully turn before performing its next action
- end
- return Use
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement