|
| 26 Nov 2011 10:31 AM |
function onTouched(hit) local function onKeyDown( key ) key: lower () if key == “f” then if hit.Parent.Humanoid~= nil then cash = game.Players:findFirstChild(hit.Parent.Name).leaderstats.Cash -- This finds who touched it and finds his money amount if cash.Value >= 1250 then -- Checks if player has enough cash cash.Value = cash.Value- 1250 -- Takes away that cash script.Parent.Parent:remove() -- Removes door if you have cash else end end end mouse.KeyDown:connect(onKeyDown) script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 10:43 AM |
...
Don't try to use a Key event within a Touched event. |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 10:55 AM |
| I can only fix this one way but idk how; how do you script for distance (like if i wanted you to only be able to open it if you were within 9 studs distance)? |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 11:12 AM |
magnitude.
if (part.CFrame.p-torso.CFrame.p).magnitude <= 10 then ~st00f~ end |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Nov 2011 11:28 AM |
Is this correct?
local function onKeyDown( key ) key: lower () if key == “f” then if (part.CFrame.p-torso.CFrame.p).magnitude <= 9 then if hit.Parent.Humanoid~= nil then cash = game.Players:findFirstChild(hit.Parent.Name).leaderstats.Cash -- This finds who touched it and finds his money amount if cash.Value >= 1250 then -- Checks if player has enough cash cash.Value = cash.Value- 1250 -- Takes away that cash script.Parent.Parent:remove() -- Removes door if you have cash else end end end mouse.KeyDown:connect(onKeyDown)
|
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 11:33 AM |
| You didn't make this script, did you? |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 11:34 AM |
Auctually I did... is it right?
|
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 11:39 AM |
| Why do you think I didn't make it? |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 26 Nov 2011 11:40 AM |
| part isnt defined in that script, or atleast the part you gave. |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 11:42 AM |
Is this correct?
local function onKeyDown( key ) key: lower () if key == “f” then if (game.Workspace.Doors.part.CFrame.p-torso.CFrame.p).magnitude <= 9 then if hit.Parent.Humanoid~= nil then cash = game.Players:findFirstChild(hit.Parent.Name).leaderstats.Cash -- This finds who touched it and finds his money amount if cash.Value >= 1250 then -- Checks if player has enough cash cash.Value = cash.Value- 1250 -- Takes away that cash script.Parent.Parent:remove() -- Removes door if you have cash else end end end mouse.KeyDown:connect(onKeyDown)
|
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 11:50 AM |
| I thought you didn't make it because you didn't change 'torso' the the Torso! Any basic scripter would know to do that! |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 11:54 AM |
Where is that?... actually some of it was copied from my brother's script. Does it work? what needs to be changed?
|
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 11:55 AM |
| The part that I gave you about magnitude. I put in 'part' and 'torso' so you would know where to put the real ones in. |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 12:07 PM |
| So waht do i change it to so it will find all players' torso? |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 12:09 PM |
| If you can't do that, I don't see how you made this. |
|
|
| Report Abuse |
|
|