Top posting users this month | |
Latest topics | » Where to go from here.September 14th 2020, 1:20 pm by MrNicNac» Send me an EmailSeptember 14th 2020, 1:16 pm by MrNicNac» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]July 6th 2015, 7:38 pm by m27frogy» New Site PossiblyJuly 6th 2015, 4:16 pm by m27frogy» Ambassador!April 15th 2015, 11:40 pm by naknak» Boop - TagApril 13th 2015, 9:46 pm by naknak» Vip Class ScriptApril 13th 2015, 4:54 pm by naknak» Who's active?!April 13th 2015, 4:52 pm by naknak» Genesis PointJuly 17th 2014, 7:04 pm by branefreez» Reward SystemJuly 17th 2014, 5:41 am by m27frogy» Script RequestJuly 10th 2014, 11:43 am by naknak» local scripts?July 10th 2014, 11:39 am by naknak» Project: Reconstruction [Died]July 10th 2014, 11:36 am by naknak» Hi. I am new hereApril 26th 2014, 4:01 pm by altshiftkey» What's your favorite sport?January 1st 2014, 2:13 pm by m27frogy» FlashLight ScriptJanuary 1st 2014, 2:11 pm by m27frogy» Gun Making! [READ DESC]January 1st 2014, 2:10 pm by m27frogy» Hi, I am new here!November 26th 2013, 3:33 pm by Keanu73» Improve CodingOctober 26th 2013, 1:12 pm by pook03» Simple ButtonSeptember 1st 2013, 6:19 pm by branefreez |
|
| Fun, fun....error -.- | |
| | Author | Message |
---|
Guest Guest
| Subject: Fun, fun....error -.- August 2nd 2010, 10:58 pm | |
| So, basically, the part doesn't go up and down the ramp correctly. It errors. Badly. I can't really explain it, but the problem is when the mode is 1. This is the script: - Code:
-
repeat wait() until game.Workspace:findFirstChild(game.Players.LocalPlayer.Name .. "_Game")
local Down = false local Origin = nil local Y_POS = workspace.Base.Position.y + 0.4 --> The position of the part on the Y-Axis local Units = {} local Selected = {} local LookOut = {}
function Search(Place, Var) for Index, Value in pairs(Place) do if Var == 0 then if Value:IsA("BasePart") and Value.Transparency > 0.9 then table.insert(LookOut, Value) elseif Value.Name == "Game_Map" then Search(Value:GetChildren(), 0) end elseif Var == 1 then if Value.Name == "Units" then Search(Value:GetChildren(), 2) end elseif Var == 2 then table.insert(Units, Value) end end end
Search(game.Workspace:GetChildren(), 0) Search(game.Workspace:findFirstChild(game.Players.LocalPlayer.Name .. "_Game"):GetChildren(), 1)
local Mode = 0 local Part = Instance.new("Part") Part.Anchored = true Part.BottomSurface = Enum.SurfaceType.Smooth Part.BrickColor = BrickColor.new("Bright green") Part.CanCollide = false Part.formFactor = Enum.FormFactor.Plate Part.TopSurface = Enum.SurfaceType.Smooth Part.Transparency = 0.3
coroutine.resume( coroutine.create( function() repeat wait() until game.Workspace:findFirstChild(game.Players.LocalPlayer.Name .. "_Game") local Model = game.Workspace:findFirstChild(game.Players.LocalPlayer.Name .. "_Game") Model.Units.DescendantAdded:connect(function(Obj) Units[table.maxn(Units)] = Obj end)
Model.DescendantRemoving:connect(function(Obj) for Index, Value in pairs(Units) do if Value == Obj then table.remove(Units, Index) end end end) end ) )
function IsInArea(Area, Checking) local Ranges = { ["X_Range"] = { Area.Position.x + Area.Size.x / 2, Area.Position.x + Area.Size.x / -2 }, ["Z_Range"] = { Area.Position.z + Area.Size.z / 2, Area.Position.z + Area.Size.z / -2 } } local Sizes = { ["X_Size"] = { Checking.Position.x + Checking.Size.x / -2, Checking.Position.x + Checking.Size.x / 2 }, ["Z_Size"] = { Checking.Position.z + Checking.Size.z / -2, Checking.Position.z + Checking.Size.z / 2 } } local True = {} if Ranges.X_Range[1] >= Sizes.X_Size[1] then table.insert(True, true) print(true) end if Ranges.X_Range[2] <= Sizes.X_Size[2] then table.insert(True, true) print(true) end if Ranges.Z_Range[1] >= Sizes.Z_Size[1] then table.insert(True, true) print(true) end if Ranges.Z_Range[2] <= Sizes.Z_Size[2] then table.insert(True, true) print(true) end if table.maxn(True) + 1 >= 4 then return true else return false end end
script.Parent.Selected:connect(function(Mouse) Mouse.Button1Down:connect(function() repeat wait() until game.Workspace:findFirstChild(game.Players.LocalPlayer.Name .. "_Game")
if Mode == 0 then if Mouse.Target ~= nil then Down = true Origin = Mouse.Hit.p end end end)
Mouse.Move:connect(function() repeat wait() until game.Workspace:findFirstChild(game.Players.LocalPlayer.Name .. "_Game")
if Mode == 0 then if Down == true and Mouse.Target ~= nil then local X = (Origin.x - Mouse.Hit.p.x) local Z = (Origin.z - Mouse.Hit.p.z) Part.Size = Vector3.new(math.abs(X), Y_POS, math.abs(Z)) Part.CFrame = CFrame.new(Vector3.new(Origin:lerp(Mouse.Hit.p, 0.5).x, Y_POS, Origin:lerp(Mouse.Hit.p, 0.5).z)) if Part.Parent == nil then Part.Parent = game.Workspace.CurrentCamera end end end end)
Mouse.Button1Up:connect(function() repeat wait() until game.Workspace:findFirstChild(game.Players.LocalPlayer.Name .. "_Game")
if Mode == 0 then Down = false for Index, Value in pairs(Units) do if IsInArea(Part, Value) then table.insert(Selected, Value) end end Part.Parent = nil Origin = nil elseif Mode == 1 and Mouse.Target ~= nil then for Index, Value in pairs(Selected) do delay(0, function() local Start = Value.CFrame.p local End = Mouse.Hit.p local Target local AtRamp = false local function Move(PreRun)
local function Path(Starting, Ending) local lookVector = CFrame.new(Starting, Ending).lookVector for Index = 0, (Ending - Starting).magnitude, 1 do for _, Value in pairs(LookOut) do if Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).x > -(Value.Size.x / 2) and Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).x < (Value.Size.x / 2) and Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).y > -(Value.Size.y / 2) and Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).y < (Value.Size.y / 2) and Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).z > -(Value.Size.z / 2) and Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).z < (Value.Size.z / 2) then return false, game.Workspace.WorkAround.CFrame.p end end end return true, nil end
if PreRun == false then if End.y > Start.y then if Value.CFrame.p.y < Start.y then return end Target = game.Workspace.PreRamp.CFrame.p --[[ if Path(Start, End) == false then local _, New = Path(Start, End) Target = New end ]] elseif End.y < Start.y then if Value.CFrame.p.y < End.y then return end Target = game.Workspace.PostRamp.CFrame.p --[[ if Path(Start, End) == false then local _, New = Path(Start, End) Target = New end ]] else Target = End end else Start = Value.CFrame.p if End.y > Start.y then if Value.CFrame.p.y > Start.y + 0.5 and Value.CFrame.p.y < End.y - 0.5 then Target = game.Workspace.PostRamp return elseif Value.CFrame.p.y > Start.y + 0.5 then Target = End return end Target = game.Workspace.PreRamp.CFrame.p --[[ if Path(Target, End) == false then local _, New = Path(Target, End) Target = New end ]] elseif End.y < Start.y then if Value.CFrame.p.y > Start.y + 0.5 and Value.CFrame.p.y < End.y - 0.5 then Target = game.Workspace.PreRamp return elseif Value.CFrame.p.y < End.y - 0.5 then Target = End return end Target = game.Workspace.PostRamp.CFrame.p --[[ if Path(Target, End) == false then local _, New = Path(Target, End) Target = New end ]] else Target = End end end for Index = 0, (Target - Start).magnitude, 1 do Value.CFrame = CFrame.new(Start:lerp(Target, Index / (Target - Start).magnitude)) wait() end if Target ~= End then Move(true) end end Move(false) end) end end end)
Mouse.KeyDown:connect(function(Key) repeat wait() until game.Workspace:findFirstChild(game.Players.LocalPlayer.Name .. "_Game")
if string.byte(Key) == 81 or string.byte(Key) == 113 then Mode = Mode - 1 if Mode < 0 then Mode = 1 end elseif string.byte(Key) == 69 or string.byte(Key) == 101 then Mode = Mode + 1 if Mode > 1 then Mode = 0 end end end) end)
You can also see it in solo mode at my place |
| | | Prodigy Administrator
Posts : 58 Join date : 2010-07-28
| Subject: Re: Fun, fun....error -.- August 2nd 2010, 11:17 pm | |
| Try removing the "Local" when you first introduced "Mode" | |
| | | Guest Guest
| Subject: Re: Fun, fun....error -.- August 2nd 2010, 11:29 pm | |
| That wouldn't do anything. The error isn't the variable, it is the mode itself. The mode is used to move your army. Mode 0 is to select them, but anyways...the error is when you try to move them up and down the ramp to the higher/lower area's of the map. |
| | | blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Fun, fun....error -.- December 18th 2010, 9:04 am | |
| Are you using a local script? | |
| | | Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: Fun, fun....error -.- January 18th 2011, 9:43 pm | |
| geez... i dont think moving a part up and down a ramp has to be that complicated. what kind of coding style do you use? your script looks messy. im. sorry. its just. insane. at least put more comments... | |
| | | Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: Fun, fun....error -.- January 18th 2011, 9:44 pm | |
| for example, this is just one of your lines of code: - Code:
-
if Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).x > -(Value.Size.x / 2) and Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).x < (Value.Size.x / 2) and Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).y > -(Value.Size.y / 2) and Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).y < (Value.Size.y / 2) and Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).z > -(Value.Size.z / 2) and Value.CFrame:pointToObjectSpace(Starting:lerp(Ending, Index / (Target - Start).magnitude)).z < (Value.Size.z / 2) then | |
| | | Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: Fun, fun....error -.- January 18th 2011, 9:45 pm | |
| are you trying to make like a strategy game or something? | |
| | | naknak Administrator
Posts : 878 Join date : 2010-07-30
| Subject: Re: Fun, fun....error -.- January 18th 2011, 10:09 pm | |
| Everyone has there own way of coding. Like for me, I just go messy so no one can read it, but I still understand :)
I doubt Voidhack will get on this site anytime soon :( | |
| | | Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: Fun, fun....error -.- January 18th 2011, 10:45 pm | |
| :( VoidHack is one of those scripters who use memory from what they learn. thats his style. i wonder how many programming books he reads. electronic or paper. | |
| | | naknak Administrator
Posts : 878 Join date : 2010-07-30
| Subject: Re: Fun, fun....error -.- January 18th 2011, 10:47 pm | |
| Probably a lot. You never builds, he literally builds his maps with scripts. | |
| | | Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: Fun, fun....error -.- January 18th 2011, 10:49 pm | |
| hmm. i think i would chose the style for quality instead of ***. i often go for effeciency first. | |
| | | naknak Administrator
Posts : 878 Join date : 2010-07-30
| Subject: Re: Fun, fun....error -.- January 18th 2011, 10:56 pm | |
| I do, too. White space may be organized, but minimum space is the most efficient. | |
| | | Supernapalm Expert Scripter
Posts : 393 Join date : 2011-01-17
| Subject: Re: Fun, fun....error -.- January 18th 2011, 11:45 pm | |
| hey what the. it blocked part of my chat. i was going to say messy instead of ***. lol. i didnt even notice that. | |
| | | blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Fun, fun....error -.- January 19th 2011, 6:42 am | |
| | |
| | | naknak Administrator
Posts : 878 Join date : 2010-07-30
| Subject: Re: Fun, fun....error -.- January 19th 2011, 8:02 pm | |
| the forums are blocked too much sometimes. Of course, I don't like staring at the censored list so I can remove it >.< | |
| | | blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Fun, fun....error -.- January 20th 2011, 8:37 am | |
| yea. I updated the site a bit! ;) | |
| | | raboy117 Novice Scripter
Posts : 75 Join date : 2011-01-19 Age : 27 Location : Canada, PEI, Charlottetown
| Subject: Re: Fun, fun....error -.- January 20th 2011, 11:01 pm | |
| | |
| | | raboy117 Novice Scripter
Posts : 75 Join date : 2011-01-19 Age : 27 Location : Canada, PEI, Charlottetown
| Subject: Re: Fun, fun....error -.- January 20th 2011, 11:01 pm | |
| | |
| | | raboy117 Novice Scripter
Posts : 75 Join date : 2011-01-19 Age : 27 Location : Canada, PEI, Charlottetown
| Subject: Re: Fun, fun....error -.- January 20th 2011, 11:01 pm | |
| | |
| | | blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Fun, fun....error -.- January 22nd 2011, 12:08 am | |
| i added to the cencored list. 0_o | |
| | | Sponsored content
| Subject: Re: Fun, fun....error -.- | |
| |
| | | | Fun, fun....error -.- | |
|
Similar topics | |
|
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| Who is online? | In total there are 12 users online :: 0 Registered, 0 Hidden and 12 Guests
None
Most users ever online was 136 on October 21st 2024, 12:16 pm
|
| Please tell us what time zone you are in here
Got a really good idea? Post it in projects and it might show up here! |
|