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 » Scripters
Home Search
 

Re: What's wrong with this script?

Previous Thread :: Next Thread 
ObstacleOfTheYear is not online. ObstacleOfTheYear
Joined: 07 Feb 2009
Total Posts: 64
30 Jan 2015 04:08 PM
So I'm trying to get it so this block is upgraded, changed size and then when touched gives the player 50 'Cash'

function onTouched(hit)
if hit.Name == "UpgradedTycoonBrick" then
hit.Size = Vector3.new(2,1,2) -- Changes Size in order X,Y,Z
hit.BrickColor = BrickColor.new(24) -- Changes Color
hit.BottomSurface = 0 -- don't change
hit.TopSurface = 0 -- don't change
hit.Name = "Cheese"

amnt = 50
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Cash")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
script.Parent:remove()
end
end
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
ObstacleOfTheYear is not online. ObstacleOfTheYear
Joined: 07 Feb 2009
Total Posts: 64
31 Jan 2015 04:00 AM
I know it's 2 scripts in 1 but it has to be for this to work...
Report Abuse
HelpfulToasty is not online. HelpfulToasty
Joined: 20 Dec 2013
Total Posts: 152
31 Jan 2015 04:04 AM
Line... further then 7, you use "local h = part.Parent:findFirstChild("Humanoid")"
What is "part"? It isn't really defined.

Also, what's the Output / Outcome(what happens) of the script?
Report Abuse
parkiet3 is not online. parkiet3
Joined: 16 Jul 2011
Total Posts: 832
31 Jan 2015 04:13 AM
? I dont get it, so if a part touches called upgradedtycoonbrick it only passes and what the hell is part?
Report Abuse
parkiet3 is not online. parkiet3
Joined: 16 Jul 2011
Total Posts: 832
31 Jan 2015 04:15 AM
Maybe you mean this:

local hit = script.Parent

function onTouched(part)
if hit.Name == "UpgradedTycoonBrick" then
hit.Size = Vector3.new(2,1,2) -- Changes Size in order X,Y,Z
hit.BrickColor = BrickColor.new(24) -- Changes Color
hit.BottomSurface = 0 -- don't change
hit.TopSurface = 0 -- don't change
hit.Name = "Cheese"

end

amnt = 50
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Cash")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
script.Parent:Destroy()
end
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
ObstacleOfTheYear is not online. ObstacleOfTheYear
Joined: 07 Feb 2009
Total Posts: 64
31 Jan 2015 10:48 AM
Ok, so what happens is a block enters, it's supposed to be 2,1,2 and if touched adds 50 'Cash'.

The script I originally put and the new script from parkiet both do nothing, so I'm really confused because my scripting isn't the best (as you have probably found out) and can't figure out a solution.

Thanks for everyone helping so far :D!
Report Abuse
ObstacleOfTheYear is not online. ObstacleOfTheYear
Joined: 07 Feb 2009
Total Posts: 64
31 Jan 2015 10:51 AM
Also, whilst I am on the subject, with this script how do I get it so if it is touched by anything (humanoid included) it'll still function? I am not sure how to:
amnt = 1
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Cash")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
script.Parent:remove()
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
ObstacleOfTheYear is not online. ObstacleOfTheYear
Joined: 07 Feb 2009
Total Posts: 64
01 Feb 2015 11:37 AM
Still can't figure it out
Report Abuse
ObstacleOfTheYear is not online. ObstacleOfTheYear
Joined: 07 Feb 2009
Total Posts: 64
02 Feb 2015 05:34 AM
bump.
Report Abuse
Ruinable is not online. Ruinable
Joined: 14 Sep 2014
Total Posts: 8903
02 Feb 2015 05:56 AM
Adding a line in between doesn't end a function, sir.
Report Abuse
ObstacleOfTheYear is not online. ObstacleOfTheYear
Joined: 07 Feb 2009
Total Posts: 64
02 Feb 2015 07:40 AM
Yeah, realised. Derp xD

Using this:

amnt = 50
local hit = script.Parent

function onTouched(part)
if hit.Name == "UpgradedTycoonBrick" then
hit.Size = Vector3.new(2,1,2) -- Changes Size in order X,Y,Z
hit.BrickColor = BrickColor.new(24) -- Changes Color
hit.BottomSurface = 0 -- don't change
hit.TopSurface = 0 -- don't change
hit.Name = "Cheese"

end

local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Cash")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
script.Parent:Destroy()
end
end


script.Parent.Touched:connect(onTouched)

Still results in nothing happening
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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