A Roblox Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeLatest imagesRegisterLog in
If you're a experienced coder make some tutorials! It would really help the site grow.
Make sure you read the rules(Which can be found by clicking here)
If you're a beginner at coding, try some tutorials.
We have many Moderators/Admins watching this site. Contact them with Questions.
Let us know what your favorite sport is. By clicking here to vote (Click here)
This site is becoming inactive. Lets make it active.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Top posters
blueymaddog
Fun, fun....error -.- Vote_lcapFun, fun....error -.- Voting_barFun, fun....error -.- Vote_rcap 
naknak
Fun, fun....error -.- Vote_lcapFun, fun....error -.- Voting_barFun, fun....error -.- Vote_rcap 
Supernapalm
Fun, fun....error -.- Vote_lcapFun, fun....error -.- Voting_barFun, fun....error -.- Vote_rcap 
m27frogy
Fun, fun....error -.- Vote_lcapFun, fun....error -.- Voting_barFun, fun....error -.- Vote_rcap 
slayer9365
Fun, fun....error -.- Vote_lcapFun, fun....error -.- Voting_barFun, fun....error -.- Vote_rcap 
myrco919
Fun, fun....error -.- Vote_lcapFun, fun....error -.- Voting_barFun, fun....error -.- Vote_rcap 
branefreez
Fun, fun....error -.- Vote_lcapFun, fun....error -.- Voting_barFun, fun....error -.- Vote_rcap 
ninga95
Fun, fun....error -.- Vote_lcapFun, fun....error -.- Voting_barFun, fun....error -.- Vote_rcap 
CloneTrooper787
Fun, fun....error -.- Vote_lcapFun, fun....error -.- Voting_barFun, fun....error -.- Vote_rcap 
raboy117
Fun, fun....error -.- Vote_lcapFun, fun....error -.- Voting_barFun, fun....error -.- Vote_rcap 
Top posting users this month
No user
Latest topics
» Where to go from here.
Fun, fun....error -.- EmptySeptember 14th 2020, 1:20 pm by MrNicNac

» Send me an Email
Fun, fun....error -.- EmptySeptember 14th 2020, 1:16 pm by MrNicNac

» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]
Fun, fun....error -.- EmptyJuly 6th 2015, 7:38 pm by m27frogy

» New Site Possibly
Fun, fun....error -.- EmptyJuly 6th 2015, 4:16 pm by m27frogy

» Ambassador!
Fun, fun....error -.- EmptyApril 15th 2015, 11:40 pm by naknak

» Boop - Tag
Fun, fun....error -.- EmptyApril 13th 2015, 9:46 pm by naknak

» Vip Class Script
Fun, fun....error -.- EmptyApril 13th 2015, 4:54 pm by naknak

» Who's active?!
Fun, fun....error -.- EmptyApril 13th 2015, 4:52 pm by naknak

» Genesis Point
Fun, fun....error -.- EmptyJuly 17th 2014, 7:04 pm by branefreez

» Reward System
Fun, fun....error -.- EmptyJuly 17th 2014, 5:41 am by m27frogy

» Script Request
Fun, fun....error -.- EmptyJuly 10th 2014, 11:43 am by naknak

» local scripts?
Fun, fun....error -.- EmptyJuly 10th 2014, 11:39 am by naknak

» Project: Reconstruction [Died]
Fun, fun....error -.- EmptyJuly 10th 2014, 11:36 am by naknak

» Hi. I am new here
Fun, fun....error -.- EmptyApril 26th 2014, 4:01 pm by altshiftkey

» What's your favorite sport?
Fun, fun....error -.- EmptyJanuary 1st 2014, 2:13 pm by m27frogy

» FlashLight Script
Fun, fun....error -.- EmptyJanuary 1st 2014, 2:11 pm by m27frogy

» Gun Making! [READ DESC]
Fun, fun....error -.- EmptyJanuary 1st 2014, 2:10 pm by m27frogy

» Hi, I am new here!
Fun, fun....error -.- EmptyNovember 26th 2013, 3:33 pm by Keanu73

» Improve Coding
Fun, fun....error -.- EmptyOctober 26th 2013, 1:12 pm by pook03

» Simple Button
Fun, fun....error -.- EmptySeptember 1st 2013, 6:19 pm by branefreez


 

 Fun, fun....error -.-

Go down 
5 posters
AuthorMessage
Guest
Guest
avatar



Fun, fun....error -.- Empty
PostSubject: Fun, fun....error -.-   Fun, fun....error -.- EmptyAugust 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
Back to top Go down
Prodigy
Administrator
Administrator
avatar


Posts : 58
Join date : 2010-07-28

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyAugust 2nd 2010, 11:17 pm

Try removing the "Local" when you first introduced "Mode"
Back to top Go down
http://roblox.forumclan.com
Guest
Guest
avatar



Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyAugust 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.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyDecember 18th 2010, 9:04 am

Are you using a local script?
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 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...
Back to top Go down
http://hackthissite.org
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 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
Back to top Go down
http://hackthissite.org
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 18th 2011, 9:45 pm

are you trying to make like a strategy game or something?
Back to top Go down
http://hackthissite.org
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 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 :(
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 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.
Back to top Go down
http://hackthissite.org
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 18th 2011, 10:47 pm

Probably a lot. You never builds, he literally builds his maps with scripts.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 18th 2011, 10:49 pm

hmm. i think i would chose the style for quality instead of ***. i often go for effeciency first.
Back to top Go down
http://hackthissite.org
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 18th 2011, 10:56 pm

I do, too. White space may be organized, but minimum space is the most efficient.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 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.
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 19th 2011, 6:42 am

lol
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 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 >.<
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 20th 2011, 8:37 am

yea. I updated the site a bit! ;)
Back to top Go down
raboy117
Novice Scripter
Novice Scripter
raboy117


Posts : 75
Join date : 2011-01-19
Age : 27
Location : Canada, PEI, Charlottetown

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 20th 2011, 11:01 pm

Lol
Back to top Go down
raboy117
Novice Scripter
Novice Scripter
raboy117


Posts : 75
Join date : 2011-01-19
Age : 27
Location : Canada, PEI, Charlottetown

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 20th 2011, 11:01 pm

Lol
Back to top Go down
raboy117
Novice Scripter
Novice Scripter
raboy117


Posts : 75
Join date : 2011-01-19
Age : 27
Location : Canada, PEI, Charlottetown

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 20th 2011, 11:01 pm

Again???
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- EmptyJanuary 22nd 2011, 12:08 am

i added to the cencored list. 0_o
Back to top Go down
Sponsored content





Fun, fun....error -.- Empty
PostSubject: Re: Fun, fun....error -.-   Fun, fun....error -.- Empty

Back to top Go down
 
Fun, fun....error -.-
Back to top 
Page 1 of 1
 Similar topics
-
» My Script error
» Script with error somewhere .....

Permissions in this forum:You cannot reply to topics in this forum
A Roblox Community :: Questions and Help :: Scripting-
Jump to: