|
| 11 Jun 2014 07:16 AM |
I'm a newbie with scripting, and I have been working for the last 20 minutes to figure out what the problem is and I keep changing lines of code here and there. The point of the script is to teleport the player that clicks it to a certain location. I haven't really set the CFrame values yet. Here's the script:
function onClicked(playerWhoClicked)
Workspace:FindFirstChild("Humanoid")
Humanoid.Parent.Torso.CFrame = CFrame.new(3, 3, 3)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
*(end of script)*
The error I get happens only once I click the part. It reads that there was an attempt to index global "Humanoid" (A nil value) |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Jun 2014 07:22 AM |
| It is supposed to be a basic script which I inserted in a specially named Part. The part has a click detector and that script in it. |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2014 07:26 AM |
function onClicked(player)
Humanoid = player.Character:WaitForChild("Humanoid")
Humanoid.Parent.Torso.CFrame = CFrame.new(3, 3, 3)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
|
| 11 Jun 2014 07:27 AM |
| It worked! Thanks a bunch. The problem was solved and now I teleport upon clicking the block. |
|
|
| Report Abuse |
|
|