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: Huge Vector3 Error

Previous Thread :: Next Thread 
JonathanW123 is not online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
07 May 2014 04:29 PM
Here is the error :

17:28:25.029 - attempt to multiply a Vector3 with an incompatible value type or nil; returning new zero-vector

So I ask for your help. I listed the functions of my script that deal with Vector3. Where is the problem? Please help

Function #1

function chooseMap()
print("Choosing Map...")
local mapID = math.random(1, #game.ServerStorage.Maps:GetChildren())
map = game.ServerStorage.Maps:findFirstChild("Map" .. mapID):Clone()
wait(20)
map.Parent = game.Workspace
map:MoveTo(Vector3.new(500, 100, 350))
print("Map chosen! Map: " .. map.Name)
wait(3)
for i, plr in pairs(game.Players:GetPlayers()) do
if plr.canPlay.Value then
plr.PlayerGui:findFirstChild("BlackScreen"):Destroy()
plr.PlayerGui.TimeLeft.Background.Visible = true
if plr.job.Value == "Death" then
spawn = math.random(1, #map.Spawns.DeathSpawns:GetChildren())
plr.Character:MoveTo(Vector3.new(map.Spawns.DeathSpawns:findFirstChild("DeathSpawn" .. spawn).Position.X, map.Spawns.DeathSpawns:findFirstChild("DeathSpawn" .. spawn).Position.Y + 1, map.Spawns.DeathSpawns:findFirstChild("DeathSpawn" .. spawn).Position.Z))
for i, weapon in pairs(game.ServerStorage.DeathWeapons:GetChildren()) do
if weapon:IsA("Tool") then
local cweap = weapon:Clone()
cweap.Parent = plr.Backpack
print(cweap.Name .. " has been loaded.")
end
end
print("Death's weapons have been loaded!")
wait()
else
spawn = math.random(1, #map.Spawns.PoliceSpawns:GetChildren())
plr.Character:MoveTo(Vector3.new(map.Spawns.PoliceSpawns:findFirstChild("PoliceSpawn" .. spawn).Position.X, map.Spawns.PoliceSpawns:findFirstChild("PoliceSpawn" .. spawn).Position.Y + 1, map.Spawns.PoliceSpawns:findFirstChild("PoliceSpawn" .. spawn).Position.Z))
game.Workspace.guardsLeft.Value = game.Workspace.guardsLeft.Value + 1
for i, weapon in pairs(game.ServerStorage.PoliceWeapons:GetChildren()) do
if weapon:IsA("Tool") then
local cweap = weapon:Clone()
cweap.Parent = plr.Backpack
print(cweap.Name .. " has been loaded.")
end
end
print("The current police guard weapons have been loaded!")
wait()
end
end
end
wait(5)
gameplay(180)
end

Function #2

function morph()
wait(5)
for i, plr in pairs(game.Players:GetPlayers()) do
if plr.canPlay.Value then
plr:ClearCharacterAppearance()
if plr.job.Value == "Death" then -- The morphing begins...
plr.Character:findFirstChild("Head").BrickColor = BrickColor.new("Really black")
plr.Character:findFirstChild("Right Arm").BrickColor = BrickColor.new("Really black")
plr.Character:findFirstChild("Left Arm").BrickColor = BrickColor.new("Really black")
plr.Character:findFirstChild("Right Leg").BrickColor = BrickColor.new("Really black")
plr.Character:findFirstChild("Left Leg").BrickColor = BrickColor.new("Really black")
plr.Character:findFirstChild("Torso").BrickColor = BrickColor.new("Really black")
plr.Character:findFirstChild("Head").Transparency = 0
plr.Character:findFirstChild("Right Arm").Transparency = 0.5
plr.Character:findFirstChild("Left Arm").Transparency = 0.5
plr.Character:findFirstChild("Right Leg").Transparency = 0.5
plr.Character:findFirstChild("Left Leg").Transparency = 0.5
plr.Character:findFirstChild("Torso").Transparency = 0.5
print("MORPHING> 50% Complete")

local mesh = Instance.new("SpecialMesh") -- Adds the dominus
mesh.MeshId = "http://www.roblox.com/asset/?id=21057410"
mesh.MeshType = Enum.MeshType.FileMesh
mesh.Scale = Vector3.new(1.05, 1.05, 1.05)
mesh.TextureId = "http://www.roblox.com/asset/?id=21249718"
mesh.Parent = plr.Character.Head
print("MORPHING> 100% Complete")
else
plr.Character:findFirstChild("Head").BrickColor = BrickColor.new("Light orange")
plr.Character:findFirstChild("Right Arm").BrickColor = BrickColor.new("Light orange")
plr.Character:findFirstChild("Left Arm").BrickColor = BrickColor.new("Light orange")
plr.Character:findFirstChild("Right Leg").BrickColor = BrickColor.new("Light orange")
plr.Character:findFirstChild("Left Leg").BrickColor = BrickColor.new("Light orange")
plr.Character:findFirstChild("Torso").BrickColor = BrickColor.new("Light orange")
print("MORPHING> 20% Complete")

local pants = Instance.new("Pants") -- Adds the pants
pants.PantsTemplate = "http://www.roblox.com/asset/?id=70968035"
print("MORPHING> 40% Complete")

local shirt = Instance.new("Shirt") -- Adds the shirt
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=48732744"
print("MORPHING> 60% Complete")

local police_hat = Instance.new("Hat") -- Adds the police hat
police_hat.Name = "PoliceCap"
police_hat.AttachmentPos = Vector3.new(0, 0, 0.1)
print("MORPHING> 80% Complete")

-- Sets the parents' of the items to the character --
pants.Parent = plr.Character
shirt.Parent = plr.Character
police_hat.Parent = plr.Character
print("MORPHING> 100% Complete")
end
end
end
print("MORPHING> Finished!")
chooseMap()
end

Report Abuse
JonathanW123 is not online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
07 May 2014 04:34 PM
Anyone?
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
07 May 2014 04:37 PM
Use more variables.

This code is unbelievably inefficient and error prone:
spawn = math.random(1, #map.Spawns.DeathSpawns:GetChildren())
plr.Character:MoveTo(Vector3.new(map.Spawns.DeathSpawns:findFirstChild("DeathSpawn" .. spawn).Position.X, map.Spawns.DeathSpawns:findFirstChild("DeathSpawn" .. spawn).Position.Y + 1, map.Spawns.DeathSpawns:findFirstChild("DeathSpawn" .. spawn).Position.Z))
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