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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Is this how to make a giver script?

Previous Thread :: Next Thread 
Grahambell is not online. Grahambell
Joined: 26 Nov 2011
Total Posts: 114
11 Feb 2014 09:26 PM
function OnTouch()
OnTouch(Hit) game.Lighting.Insert("LinkedSword").StarterPack

end
Report Abuse
Geomaster is not online. 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
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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
Grahambell is not online. Grahambell
Joined: 26 Nov 2011
Total Posts: 114
11 Feb 2014 10:13 PM
Thanks, both scripts worked perfectly!
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
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 is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
11 Feb 2014 11:18 PM
workspeis.humein:2] give sword wen toucch
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
11 Feb 2014 11:21 PM
robot...
Workspace.person:giveasword()
LOL,jk,jk
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
11 Feb 2014 11:22 PM
workspeis.scrip:[1 end expected kill island
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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 is not online. 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
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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 is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
12 Feb 2014 12:04 AM
Error("island is ".. shared.swear())
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