IronNoob

Please login or register.

Login with username, password and session length
Advanced search  

News:

Migrated to dedicated hosting. Post any weirdness you observe in the Lounge.

Author Topic: Proofread  (Read 51 times)

0 Members and 1 Guest are viewing this topic.

ẆỉїǤ

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 284
    • View Profile
    • WiiG - ROBLOX
Proofread
« on: April 13, 2013, 07:17:04 pm »

Can someone tell me if this script could even potentially work? (I have never scripted before so...)
Code: [Select]
local p = Workspace.Player
if p then
local t = p.Torso

local l = Instance.new("PointLight")
l.parent = t
Logged

Roundel

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3589
    • View Profile
Re: Proofread
« Reply #1 on: April 13, 2013, 08:20:47 pm »

to close every if statement there needs to be an end statement so the code knows where to stop being 'if'
also more minor but would still be a problem is that if t is local it will only be available within the if statement, so if you want it to be local you have to make the variable before the if

like

local p = Workspace.Player
local t = nil
if p then
   t = p.Torso
end

local l = Instance.new("PointLight")
l.parent = t
Logged

ẆỉїǤ

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 284
    • View Profile
    • WiiG - ROBLOX
Re: Proofread
« Reply #2 on: April 14, 2013, 09:47:55 am »

to close every if statement there needs to be an end statement so the code knows where to stop being 'if'
also more minor but would still be a problem is that if t is local it will only be available within the if statement, so if you want it to be local you have to make the variable before the if

like

local p = Workspace.Player
local t = nil
if p then
   t = p.Torso
end

local l = Instance.new("PointLight")
l.parent = t

Okay thank you for the help.

Question: How would it be made so the script can identify any player that enters the game. Does it involve the :FindFirstChild() function?
« Last Edit: April 14, 2013, 09:57:14 am by ẆỉїǤ »
Logged

BAUER102

  • Full Member
  • ***
  • Offline Offline
  • Posts: 199
  • Full-time God
    • View Profile
Re: Proofread
« Reply #3 on: April 14, 2013, 10:49:04 am »

Question: How would it be made so the script can identify any player that enters the game. Does it involve the :FindFirstChild() function?

http://wiki.roblox.com/index.php/PlayerAdded_(Event)
Logged
German Coding Maniac
Main Twitter || Borderline Twitter || ROBLOX Account
 

Page created in 0.071 seconds with 22 queries.