generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Assigning Multiple values

Previous Thread :: Next Thread 
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
20 Jun 2012 06:58 PM
in a for loop, it clones a part for howevermany enemies there are. I'm trying to assign that part to an object value, but in a for loop it doesn't seeem to work.


output:

19:55:44 - Unknown exception
19:55:44 - Script "Workspace.Enemies.Entrance Guard (Level 15).DamageScript", Line 40
19:55:44 - stack end
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
20 Jun 2012 06:59 PM
Line 40: script.Source.Value:Destroy()
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
20 Jun 2012 07:25 PM
We need the script...
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
20 Jun 2012 08:03 PM
You cannot do that unless it is an ObjectValue.
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
20 Jun 2012 08:42 PM
It IS an objectValue.
Report Abuse
Fliers11 is not online. Fliers11
Joined: 28 Jul 2009
Total Posts: 1188
20 Jun 2012 08:44 PM
Speaking of, which should be used: destroy() or remove()?
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
20 Jun 2012 08:52 PM
@pie
I can asure you the mistake is before line 40, and since we can't see through your eyes, we would be able to help you better if you posted the script.
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
20 Jun 2012 08:59 PM
Well there are multiple scripts. I gave up on making it all in one because there was a wait(2) in there which messed up the whole "Barrage" attack thing I had. So Would running my code with the delay() coroutine work better? Example:

function print()
print("Hi")
wait(2)
end


while true do

delay(0,function()
print()
end)

wait(1)

end



stack overflow, basically that means it does what I want it to.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
20 Jun 2012 09:01 PM
@pie
Not really... You just made the print() function call itself infinitely.
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
20 Jun 2012 09:08 PM
But that's what I want... For a function to run without having to wait for the tag to be deleted to run again. Sort of like a Touched event. Runs every single the brick is touched.
Report Abuse
jode6543 is not online. jode6543
Joined: 16 Jun 2009
Total Posts: 5363
20 Jun 2012 09:16 PM
What you want, sadly, is impossible. You will need to find another way to do it.

-Jode
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
20 Jun 2012 09:18 PM
Couldn't post my script for some odd reason...
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
20 Jun 2012 09:20 PM
Put the whole part with the barrage in a coroutine (not the function, just wrap the for loop's code).

Like so:

function
for loop
coroutine.wrap(function()
-- code and wait
end)()
end
end
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
20 Jun 2012 09:25 PM
function fire()

virtualChar = Tool.Parent
virtualPlay = Game.Players:GetPlayerFromCharacter(virtualChar)

for k,z in pairs(script.Parent.Types:GetChildren()) do
if z.Value == true then
type = z
if type.Name == "Smoke" and virtualPlay.Config.Ancients.Value == true then

local function gatherEnemies()
local toReturn = {}
local e = Workspace.Enemies:GetChildren()
for i,v in pairs(e) do
if v:FindFirstChild("Zombie") and v:findFirstChild("Torso") then
if (v.Torso.Position-virtualChar.Torso.Position).magnitude <= 50 then
table.insert(toReturn, v)
end
end
end
return toReturn
end

for i,v in pairs(gatherEnemies()) do
coroutine.wrap(function()
p = Instance.new("Part")
p.CFrame = v.Torso.CFrame
p.CanCollide = false
p.Size = Vector3.new(10,10,10)
p.BrickColor = BrickColor.new("Medium stone grey")
p.Shape = "Block"
p.Transparency = 0.5
p.BottomSurface = 0
p.TopSurface = 0
p.Name = "Barrage"
p.Parent = Workspace
local force = Instance.new("BodyForce")
force.force = Vector3.new(0,p:GetMass() * 196,0)
force.Parent = p
local w = Instance.new("Weld", p)
w.Part0 = p
w.Part1 = v.Torso
w.C0 = CFrame.new(0,5,0)
hum = v:findFirstChild("Zombie")

if hum ~= nil then
local mage = virtualPlay.Config.Mage.Value
damage = damage + mage
damage = math.random(0,damage)
local new = damage * Tool.Settings.Multiplier.Value
local words = tostring(new)
local clone = virtualPlay.PlayerGui.GameGui.YourHit:Clone()
clone.Name = "HitClone"
clone.Parent = virtualPlay.PlayerGui.GameGui
clone.Text = words
clone.Script.Disabled = false
if new == 0 then
clone.TextColor = BrickColor.new("Bright blue")
elseif new > 0 then
clone.TextColor = BrickColor.new("Bright red")
end

tagHum(hum)

hum:TakeDamage(new)

wait(2)

remTag(hum)

p:Destroy()

end





end
end)()
end


output:

22:24:06 - Players.Player.Backpack.Ancient Staff.WizardStaff:97: ')' expected (to close '(' at line 42) near 'end'

Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
20 Jun 2012 11:16 PM
Bump
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
21 Jun 2012 06:34 AM
Help...
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
21 Jun 2012 08:18 AM
MNN please come back D:
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
21 Jun 2012 08:20 AM
People here only seem to fix simple problems, except KMXD, CM32, MNN, ElectricBlazer, Spectrumw, etc. etc.
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
21 Jun 2012 08:22 AM
...DXpower, Kingkiller...
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
21 Jun 2012 08:31 AM
OMG SOMEONE HELP ALREADY.
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
21 Jun 2012 08:45 AM
I came up with a new script. It functions, but it only targets one enemy and clones the brick for however many enemies are withinn 50 studs. I want each enemy to get their own brick, and their own damage taken:

function tagHum(hum)
tag = Instance.new("ObjectValue")
tag.Value = virtualPlay
tag.Name = "creator"
tag.Parent = hum
end
function remTag(hum)
tag:Destroy()
end


function fire()

virtualChar = Tool.Parent
virtualPlay = Game.Players:GetPlayerFromCharacter(virtualChar)

for k,z in pairs(script.Parent.Types:GetChildren()) do
if z.Value == true then
type = z
if type.Name == "Smoke" and virtualPlay.Config.Ancients.Value == true then

local function gatherEnemies()
local toReturn = {}
local e = Workspace.Enemies:GetChildren()
for i,v in pairs(e) do
if v:FindFirstChild("Zombie") and v:findFirstChild("Torso") then
if (v.Torso.Position-virtualChar.Torso.Position).magnitude <= 50 then
table.insert(toReturn, v)
end
end
end
return toReturn
end

for i,v in pairs(gatherEnemies()) do
function barrage()
p = Instance.new("Part")
p.CFrame = v.Torso.CFrame
p.CanCollide = false
p.Size = Vector3.new(10,10,10)
p.BrickColor = BrickColor.new("Medium stone grey")
p.Shape = "Block"
p.Transparency = 0.5
p.BottomSurface = 0
p.TopSurface = 0
p.Name = "Barrage"
p.Parent = Workspace
local force = Instance.new("BodyForce")
force.force = Vector3.new(0,p:GetMass() * 196,0)
force.Parent = p
local w = Instance.new("Weld", p)
w.Part0 = p
w.Part1 = v.Torso
w.C0 = CFrame.new(0,5,0)
hum = v:findFirstChild("Zombie")

if hum ~= nil then
local mage = virtualPlay.Config.Mage.Value
damage = damage + mage
damage = math.random(0,damage)
local new = damage * Tool.Settings.Multiplier.Value
local words = tostring(new)
local clone = virtualPlay.PlayerGui.GameGui.YourHit:Clone()
clone.Name = "HitClone"
clone.Parent = virtualPlay.PlayerGui.GameGui
clone.Text = words
clone.Script.Disabled = false
if new == 0 then
clone.TextColor = BrickColor.new("Bright blue")
elseif new > 0 then
clone.TextColor = BrickColor.new("Bright red")
end

tagHum(hum)

hum:TakeDamage(new)

wait(2)

remTag(hum)

p:Destroy()

end





end
coroutine.wrap(barrage)
end

elseif type.Name == "Blood" and virtualPlayer.Config.Ancients.Value == true then
print("Blood")
end
end
end
end
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
21 Jun 2012 08:46 AM
Sorry, wrong script:

function fire()

virtualChar = Tool.Parent
virtualPlay = Game.Players:GetPlayerFromCharacter(virtualChar)

for k,z in pairs(script.Parent.Types:GetChildren()) do
if z.Value == true then
type = z
if type.Name == "Smoke" and virtualPlay.Config.Ancients.Value == true then

local function gatherEnemies()
local toReturn = {}
local e = Workspace.Enemies:GetChildren()
for i,v in pairs(e) do
if v:FindFirstChild("Zombie") and v:findFirstChild("Torso") then
if (v.Torso.Position-virtualChar.Torso.Position).magnitude <= 50 then
table.insert(toReturn, v)
end
end
end
return toReturn
end

for i,v in pairs(gatherEnemies()) do
print("a")
function barrage()
print("b")
p = Instance.new("Part")
p.CFrame = v.Torso.CFrame
p.CanCollide = false
p.Size = Vector3.new(10,10,10)
p.BrickColor = BrickColor.new("Medium stone grey")
p.Shape = "Block"
p.Transparency = 0.5
p.BottomSurface = 0
p.TopSurface = 0
p.Name = "Barrage"
p.Parent = Workspace
pa = p:Clone()
pa.CFrame = v.Torso.CFrame
local force = Instance.new("BodyForce")
force.force = Vector3.new(0,p:GetMass() * 196,0)
force.Parent = p
local w = Instance.new("Weld", p)
w.Part0 = p
w.Part1 = v.Torso
w.C0 = CFrame.new(0,5,0)
hum = v:findFirstChild("Zombie")

if hum ~= nil then
local mage = virtualPlay.Config.Mage.Value
damage = damage + mage
damage = math.random(0,damage)
local new = damage * Tool.Settings.Multiplier.Value
local words = tostring(new)
local clone = virtualPlay.PlayerGui.GameGui.YourHit:Clone()
clone.Name = "HitClone"
clone.Parent = virtualPlay.PlayerGui.GameGui
clone.Text = words
clone.Script.Disabled = false
if new == 0 then
clone.TextColor = BrickColor.new("Bright blue")
elseif new > 0 then
clone.TextColor = BrickColor.new("Bright red")
end

tagHum(hum)

hum:TakeDamage(new)

wait(2)

remTag(hum)

p:Destroy()

end





end
delay(0,function() barrage() end)
end

elseif type.Name == "Blood" and virtualPlayer.Config.Ancients.Value == true then
print("Blood")
end
end
end
end
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
21 Jun 2012 09:36 AM
function fire()

virtualChar = Tool.Parent
virtualPlay = Game.Players:GetPlayerFromCharacter(virtualChar)

for k,z in pairs(script.Parent.Types:GetChildren()) do
if z.Value == true then
type = z
end
end
if type.Name == "Smoke" and virtualPlay.Config.Ancients.Value == true then

local function gatherEnemies()
local toReturn = {}
local e = Workspace.Enemies:GetChildren()
for i,v in pairs(e) do
if v:FindFirstChild("Zombie") and v:findFirstChild("Torso") then
if (v.Torso.Position-virtualChar.Torso.Position).magnitude <= 50 then
table.insert(toReturn, v)
end
end
end
return toReturn
end

for i,v in pairs(gatherEnemies()) do
p = Instance.new("Part")
p.CFrame = v.Torso.CFrame
p.CanCollide = false
p.Size = Vector3.new(10,10,10)
p.BrickColor = BrickColor.new("Medium stone grey")
p.Shape = "Block"
p.Transparency = 0.5
p.BottomSurface = 0
p.TopSurface = 0
p.Name = "Barrage"
p.Parent = Workspace
local force = Instance.new("BodyForce")
force.force = Vector3.new(0,p:GetMass() * 196,0)
force.Parent = p
local w = Instance.new("Weld", p)
w.Part0 = p
w.Part1 = v.Torso
w.C0 = CFrame.new(0,5,0)
hum = v:findFirstChild("Zombie")

if hum ~= nil then
local mage = virtualPlay.Config.Mage.Value
damage = damage + mage
damage = math.random(0,damage)
local new = damage * Tool.Settings.Multiplier.Value
local words = tostring(new)
local clone = virtualPlay.PlayerGui.GameGui.YourHit:Clone()
clone.Name = "HitClone"
clone.Parent = virtualPlay.PlayerGui.GameGui
clone.Text = words
clone.Script.Disabled = false
if new == 0 then
clone.TextColor = BrickColor.new("Bright blue")
elseif new > 0 then
clone.TextColor = BrickColor.new("Bright red")
end
coroutine.wrap(function()
tagHum(hum)
hum:TakeDamage(new)
wait(2)
remTag(hum)
p:Destroy()
end)()
end
end
end
end
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
21 Jun 2012 09:49 AM
You came too late MNN lol. I already fixed it by cloning scripts into the part and into the creator then disabling them. Your's is probably more efficient, so I'm keeping it just in case.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image