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
 

Head is not a valid member of workspace.... >.>

Previous Thread :: Next Thread 
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
20 Oct 2014 07:17 PM
I don't get what this error means... the script worked before I added the lucky block portion. halp plox
Script:

function onButton1Down(mouse)
print(game.Workspace[script.Parent.Parent.Parent.Name])
posp = game.Workspace[script.Parent.Parent.Parent.Name].Head.Position
local ray = Ray.new(game.Workspace[script.Parent.Parent.Parent.Name].Head.Position, mouse.Hit.p)
local hit, position = game.Workspace:FindPartOnRay(ray, game.Workspace[script.Parent.Parent.Parent.Name])

--do damage to any humanoids hit
local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")

--draw the ray
local distance = (position - posp).magnitude
local rayPart = Instance.new("Part", game.Workspace)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor.new("Bright red")
rayPart.Transparency = 0.5
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.TopSurface = Enum.SurfaceType.Smooth
rayPart.BottomSurface = Enum.SurfaceType.Smooth
rayPart.formFactor = Enum.FormFactor.Custom
rayPart.Size = Vector3.new(0.2, 0.2, distance)
rayPart.CFrame = CFrame.new(position, posp) * CFrame.new(0, 0, -distance/2)
game.Debris:AddItem(rayPart, 0.1)
if hit == nil then
elseif game.Workspace[hit.Name].type ~= nil and hit.Name:gsub(hit.Name:sub(1,4),"") == "Turbo" then
print("plane hit")
game.Workspace.explode:play()
-- game.Workspace[hit.Name].Position = Vector3.new(-68, 12, -43.5)
game.Workspace[hit.Name]:remove()
-- print(game.Workspace[hit.Name].Position)
local h = Instance.new("Hint", game.Players[script.Parent.Parent.Parent.Name].PlayerGui)
text = " "..hit.Name:gsub(hit.Name:sub(1,4), "").." destroyed."
for i = 1, #text do
h.Text = text:sub(i)
wait(.1)
end
h:remove()
elseif game.Workspace[hit.Name].placer then
local h = Instance.new("Hint", game.Players[script.Parent.Parent.Parent.Name].PlayerGui)
text = " Lucky Block Opened."
for i = 1, #text do
h.Text = text:sub(i)
wait(.1)
end
h:remove()
end


end

function onSelected(mouse)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

script.Parent.Selected:connect(onSelected)

ERROR: Head is not a valid member of Workspace

Thank you... I suck at scripting e.e

~ quarter monkey, quarter potato, half memorycode.
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
20 Oct 2014 08:01 PM
bermp.


I also have to add that the rest of the script works but when I hit the "lucky block" it breaks.
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
21 Oct 2014 01:49 PM
bumpbumpbump shake your bump
Report Abuse
thermonuklear is not online. thermonuklear
Joined: 19 Oct 2014
Total Posts: 484
21 Oct 2014 02:26 PM
not sure, but could this be a bug?
sometimes i got an error with a model, not being inside a model... when it was ;/
Report Abuse
anaIyze is not online. anaIyze
Joined: 29 May 2014
Total Posts: 2048
21 Oct 2014 02:45 PM
'posp = game.Workspace[script.Parent.Parent.Parent.Name].Head.Position'
'game.Workspace[script.Parent.Parent.Parent.Name].Head.Position'
'[script.Parent.Parent.Parent.Name].Head.Position'
'[script.Parent.Parent.Parent`.Name`].Head'
'.Name'

Lol
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
21 Oct 2014 06:08 PM
What about it??

That shouldn't error the code... it works for the other elseif statements.

Report Abuse
jr41901 is not online. jr41901
Joined: 03 Mar 2013
Total Posts: 35
21 Oct 2014 06:31 PM
wouldent the head be a part of the players model and not a child of workspace?
Report Abuse
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
21 Oct 2014 06:57 PM
game.Workspace[hit.Name]

All of the lines that say this to find the head should be

game.Workspace[hit.Parent.Name]

just make sure there wont be anything with the same name as a player in workspace
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