|
| 17 Oct 2015 02:36 PM |
Can anyone help me. This current script records gameplay the whole time. I need it to only show the last 20 seconds of what it has recorded.
Script: ============================================================================ _G.IR=script;--so other scripts can find this ---------------------- ---define variables--- ---------------------- local ball=script.Ball;--the object to follow local reset=script.Reset;--Starts over the filming local show=script.ShowReplay;--Starts the replay local stopped=script.Stopped;--stops recording local offset=script.Displacement;--how far off should the players cameras be from the ball? local maxValue=script.MaxHeight;--the maximum height the camera can reach local seconds=script.Seconds;--how many seconds of gameplay to save local players={};--character models of each player local film={};--the current data being stored local playing=false;--is a film playing or not?
---------------------- ---define functions--- ----------------------
--deletes an object function delete(obj) game:GetService("Debris"):AddItem(obj,0); end
--adds a new player to the list function addPlayer(playa) repeat wait(); until playa.Character wait(2); playa.Character.Archivable=true; players[playa.Name]=playa.Character:clone(); playa.Character.Archivable=false; end
--adds a new frame to the film function addFrame(film) local frame={};--the new frame --get the location of every player and save it for _,player in pairs(game.Players:GetChildren()) do if player.Character and player.Character:findFirstChild("Torso") and players[player.Name] then frame[player.Name]={}; frame[player.Name].Torso=player.Character.Torso.CFrame; pcall(function() frame[player.Name].LA=player.Character["Left Arm"].CFrame; end); pcall(function() frame[player.Name].RA=player.Character["Right Arm"].CFrame; end); pcall(function() frame[player.Name].LL=player.Character["Left Arm"].CFrame; end); pcall(function() frame[player.Name].RL=player.Character["Right Leg"].CFrame; end); end end --get the location of the ball and the ball carrier if ball.Value and ball.Value.Parent then frame["__ball"]={ obj=ball.Value:clone(); ball=ball.Parent:IsA("Model") and ball or ball.Parent; pos=ball.Value:findFirstChild("Handle") and ball.Value.Handle.CFrame or ball.Value.CFrame; parent=ball.Value.Parent and (ball.Value.Parent:IsA("Model") and ball.Value.Parent.Name or ball.Value.Parent.Parent.Name); }; else frame["__ball"]={pos=CFrame.new();}; end --add to film if #film>seconds.Value/0.03 then table.remove(film,1); end table.insert(film,frame); end
--displays a film function rollFilm(film) --if no other film is playing if not playing then --create a new value to display the CFrame of the camera local pos=Instance.new("CFrameValue",script); pos.Name="Position"; --Destroy all characters, balls and insert LocalScripts pcall(function() ball.Value:Destroy(); end); for _,player in pairs(game.Players:GetChildren()) do pcall(function() addPlayer(player); end); pcall(function() delete(player.Character); end); local a=script.LocalScript:clone(); a.Parent=player.PlayerGui; a.Pos.Value=pos; end --create a model for all of the character models local chars=Instance.new("Model",workspace); local ball;--the ball if any --start running the film playing=true; for time,frame in ipairs(film) do print(time); wait(0.1); --destroy old ball pcall(function() delete(ball); end); --go through each player/object in the frame for name,data in pairs(frame) do --check if it is a player if name~="__ball" then --check if player already exists if chars:findFirstChild(name) then chars[name].Torso.CFrame=data.Torso; pcall(function() playa["Left Arm"].CFrame=data.LA; end); pcall(function() playa["Right Arm"].CFrame=data.RA; end); pcall(function() playa["Left Leg"].CFrame=data.LL; end); pcall(function() playa["Right Leg"].CFrame=data.RL; end); else --add new player local playa=players[name]:clone(); playa.Parent=chars; playa:MakeJoints(); playa.Humanoid.PlatformStand=true; playa.Torso.Anchored=true; playa.Torso.CFrame=data.Torso; pcall(function() playa["Left Arm"].CFrame=data.LA; end); pcall(function() playa["Right Arm"].CFrame=data.RA; end); pcall(function() playa["Left Leg"].CFrame=data.LL; end); pcall(function() playa["Right Leg"].CFrame=data.RL; end); for _,v in pairs(playa.Torso:GetChildren()) do if v:IsA("Weld") and v.Name~="Neck" then v:Destroy(); end end end --if it is the ball else --check if there is a ball at this frame if data.obj and data.parent then ball=data.obj:clone(); ball.CFrame=data.pos; ball.Parent=workspace; end --set the position of the camera pos.Value=CFrame.new(data.pos.p+offset.Value,data.pos.p); pos.Value=CFrame.new(pos.Value.p.x,math.min(maxValue.Value,pos.Value.p.y),pos.Value.p.z)* (pos.Value-pos.Value.p); end end end --get ready to begin again pcall(function() delete(chars); end); pcall(function() delete(ball); end); pcall(function() delete(pos); end); playing=false; --load everyones characters again for _,v in pairs(game.Players:GetChildren()) do v:LoadCharacter(); end end end
-------------- ---run code--- --------------
--add player every time someone enters the game game.Players.PlayerAdded:connect(function(player) --player:LoadCharacter(); addPlayer(player); if playing then delete(player.Character); local a=script.LocalScript:clone(); a.Parent=player.PlayerGui; a.Pos.Value=script.Position; end end );
--resets the film every time changed reset.Changed:connect(function() if reset.Value then film={}; reset.Value=false; end end );
--check for if it should start displaying or not show.Changed:connect(function() if show.Value then rollFilm(film); show.Value=false; end end );
--add a new frame while wait() do if not stopped.Value and not playing then addFrame(film); end end
|
|
|
| Report Abuse |
|
|
|
| 17 Oct 2015 02:57 PM |
| Is no one talented enough to solve this :/ |
|
|
| Report Abuse |
|
|
|
| 17 Oct 2015 02:58 PM |
I just don't have the time to read through it all right now.
-The [Guy] |
|
|
| Report Abuse |
|
|
|
| 17 Oct 2015 03:02 PM |
| Yeah, I don't wanna sit here reading lines of code either. |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2015 09:23 AM |
| I could really use the help |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2015 09:31 AM |
I can't write code for this, but I can tell you how to do it:
If you want it to show the last 20 seconds, first you need to take the amount of frames it records per second and multiply it by 20 to get the number of frames in 20 seconds. Then you need to get the total number of frames, subtract the number of frames in 20 seconds from that, and then you get the number of frames that have been recorded before the last 20 seconds. Iterate over the table of frames starting at that number and it'll only iterate over the last 20 seconds. |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2015 09:34 AM |
Don't just demand for "advanced scripters only". That's a new form of discrimination.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2015 10:08 AM |
| I'm not very advanced, and I'm not going to read that whole thing. |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 18 Oct 2015 10:10 AM |
"function delete(obj) game:GetService("Debris"):AddItem(obj,0); end"
"Advanced scripters only"
a lot of code
how about no |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Oct 2015 11:10 PM |
| so many views, so little help0 |
|
|
| Report Abuse |
|
|
tears3106
|
  |
| Joined: 15 Jul 2009 |
| Total Posts: 1396 |
|
|
| 26 Oct 2015 12:52 AM |
| As everyone else said, I don't have time to sit a look for one error in this. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 26 Oct 2015 04:55 PM |
| Ok; i know how to fix this but since i'm not "advanced" i can't tell you, sorry. |
|
|
| Report Abuse |
|
|
Saldor010
|
  |
| Joined: 20 Sep 2010 |
| Total Posts: 1035 |
|
|
| 26 Oct 2015 05:13 PM |
| Oh no! I'm only an intermediate scripter! No help for you, noob. |
|
|
| Report Abuse |
|
|
|
| 26 Oct 2015 05:38 PM |
function delete(obj) game:GetService("Debris"):AddItem(obj,0); end"
Wth? Use Destroy noob. |
|
|
| Report Abuse |
|
|