|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
| |
|
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 |
|
|
|
| 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 |
|
|