|
| 11 Feb 2014 09:26 PM |
function OnTouch() OnTouch(Hit) game.Lighting.Insert("LinkedSword").StarterPack
end |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 11 Feb 2014 09:58 PM |
Oh my word..
Well, first off, let me explain what you WANT to do
Functions have whatever code you put into them. Basically, when you make a function, you're telling the script that the function does what you want it to do. The script can't use that function unless you tell it WHEN to use the function.
Let's say you put a script in a part, and you want that part to give people a sword.
The script should have this in it:
main = script.Parent -- The script is inside the Part, and we'll call the Part 'main' to save space
function giveSword(hit) -- We can name our function whatever we want, 'hit' is the part that touches main local player = game.Players:findFirstChild(hit.Parent.Name) -- Find the player who touched main local sword = game.Lighting:findFirstChild("LinkedSword") -- Our sword if player and sword then -- If we have a player and our sword isn't missing sword:clone().Parent = player.Backpack -- Clone the tool to the player end end
script.Parent.Touched:connect(giveSword) -- We tell the script to use giveSword when main is touched |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2014 10:07 PM |
aw,i was gonna say that..kinda
u should also have a debounce,otherwise,itll clone infinite swords
deb = false
timeuntilcantouchagain = 3--change this
script.Parent.Touched:connect(function(thing)--thing is what touched it p = game.Players:FindFirstChild(thing.Parent.Name)--this is the player s = game.Lighting:findFirstChild("WeaponNameHere")--this is the weapon if p and s and not deb then -- if its a player,and we have the sword and its --not "debouncing" then deb = true--make it "debounce" s:clone().Parent = p.Backpack--clone it to the backpack s:clone().Parent = p.StarterGear--remove this line if u only want them to have --it until they die wait(timeuntilcantouchagain) deb = false end end) |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2014 10:13 PM |
| Thanks, both scripts worked perfectly! |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2014 10:27 PM |
glad to hear that,try going to: http://wiki.roblox.com/index.php?title=Scripting and other pages at wiki.roblox.com :P |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2014 11:11 PM |
I laughed so hard at the script you made graham, no offense. Mhm, I remember when I started scripting... I failed really bad too xD |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
|
| 11 Feb 2014 11:18 PM |
| workspeis.humein:2] give sword wen toucch |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2014 11:21 PM |
robot... Workspace.person:giveasword() LOL,jk,jk |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
|
| 11 Feb 2014 11:22 PM |
| workspeis.scrip:[1 end expected kill island |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2014 11:27 PM |
I got an error with this script... a = "cipe" print (string.reverse(a.."si agem tobor")) heres the error.. 22:25:51.250 - a = "cipe" print (string.reverse(a.."si agem tobor")):1: attempt to concatenate global 'a' (a nil value) |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
|
| 11 Feb 2014 11:31 PM |
k wat u gotta do with a = "cipe" print (string.reverse(a.."si agem tobor")) is
createee=setmetatable({},{ __newindex=function(t,key,value) rawset(t,key,string.reverse(tostring(value))) end })
createee.yes="cipe si agem tobor" print(createee.yes) |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2014 11:35 PM |
now it says Error in Script:cannot lie about something so obvious,have you tried changing "robot mega" to "islandmaker2012"? |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
|
| 12 Feb 2014 12:04 AM |
| Error("island is ".. shared.swear()) |
|
|
| Report Abuse |
|
|