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: Creating a script with instance.new

Previous Thread :: Next Thread 
CoolArik1 is not online. CoolArik1
Joined: 18 Sep 2011
Total Posts: 59
23 Nov 2013 02:03 PM
The script works like this:

local o = Instance.new("Script")
o.Parent = game.Workspace.Baseplate.Part
o.Source = [[
function onTouched(hit)
if not hit or not hit.Parent then return end
local human = hit.Parent:findFirstChild("Humanoid")
if human and human:IsA("Humanoid") then
human.Health = 0
Instance.new('Fire', human.Parent.Head).Name = "Burn"
Instance.new('Fire', human.Parent.Torso).Name = "Burn"
Instance.new('Fire', human.Parent["Right Arm"]).Name = "Burn"
Instance.new('Fire', human.Parent["Left Arm"]).Name = "Burn"
Instance.new('Fire', human.Parent["Right Leg"]).Name = "Burn"
Instance.new('Fire', human.Parent["Left Leg"]).Name = "Burn"
human.Parent.Head.Burn.Size = 10
human.Parent.Torso.Burn.Size = 10
human.Parent["Right Arm"].Burn.Size = 10
human.Parent["Left Arm"].Burn.Size = 10
human.Parent["Right Leg"].Burn.Size = 10
human.Parent["Left Leg"].Burn.Size = 10
end
end

script.Parent.Touched:connect(onTouched)
]]

Anyone know what I did wrong? Thanks in advance!
Report Abuse
CoolArik1 is not online. CoolArik1
Joined: 18 Sep 2011
Total Posts: 59
23 Nov 2013 02:04 PM
Oh sorry I can't find a edit button, but the error happens on the line with

]]

Otherwise the last line. Sorry.
Report Abuse
chickenman158 is not online. chickenman158
Joined: 18 Jan 2011
Total Posts: 915
23 Nov 2013 02:05 PM
Script.Source is rbxlocked

Use loadstring() and StringValues instead.
Report Abuse
Wakarimasu is not online. Wakarimasu
Joined: 12 Nov 2013
Total Posts: 1448
23 Nov 2013 02:06 PM
Or you can copy a disabled version of the script from elsewhere and then enable it in the player.
Report Abuse
ToxicDominator is not online. ToxicDominator
Joined: 24 Oct 2013
Total Posts: 8373
23 Nov 2013 02:06 PM
Source is locked
Report Abuse
CoolArik1 is not online. CoolArik1
Joined: 18 Sep 2011
Total Posts: 59
23 Nov 2013 02:07 PM
Oh. I didn't know source was locked. But how would I use loadstring() and StringValues?
Report Abuse
ToxicDominator is not online. ToxicDominator
Joined: 24 Oct 2013
Total Posts: 8373
23 Nov 2013 02:09 PM
str=Instance.new("StringValue",workspace)
str.Value=""
loadstring(str.Value)()
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
23 Nov 2013 02:10 PM
It is recommended to always use pcall with loadstring, in case the string errors. That way it wont break the script calling it.

pcall(loadstring("--your code here"))

Never Trust Roblox.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Nov 2013 02:12 PM
^ You mean the people?
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
23 Nov 2013 02:17 PM
I mean Roblox Studio. It does some really weird stuff...Never trust that something has been done successfully if you don't have complete control over its implementation. Even then Roblox sometimes treats integers as strings and crazy trippy stuff like that.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Nov 2013 02:17 PM
No, just no.
There is no such thing as an integer in Lua.
Report Abuse
CoolArik1 is not online. CoolArik1
Joined: 18 Sep 2011
Total Posts: 59
23 Nov 2013 02:26 PM
Sadly I am new to LUA, so I can't figure out how the string works. I pasted the code and put tabs to separate lines since it would only go on one line. I feel bad for asking but may you please take this code and make it work in a string? Thanks again!
Report Abuse
ToxicDominator is not online. ToxicDominator
Joined: 24 Oct 2013
Total Posts: 8373
23 Nov 2013 02:26 PM
What's LUA
Report Abuse
CoolArik1 is not online. CoolArik1
Joined: 18 Sep 2011
Total Posts: 59
23 Nov 2013 02:31 PM
Lua is a scripting code and I think it is what roblox uses. I could be wrong though. (I usually am wrong.)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Nov 2013 02:38 PM
It's a scripting language and roblox does in fact, use a version of Lua
Report Abuse
ToxicDominator is not online. ToxicDominator
Joined: 24 Oct 2013
Total Posts: 8373
23 Nov 2013 02:39 PM
"LUA" ~= "Lua"
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
23 Nov 2013 02:42 PM
It isn't, but we all knew what he was talking about.
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