Plutoeros
|
  |
| Joined: 13 Feb 2016 |
| Total Posts: 214 |
|
|
| 29 Apr 2017 08:27 AM |
It's kind of what the title implies, but I haven't included the fact that when the brick would be touched, the CameraMode of the player would lock into first person. I've tried multiple methods to work around it, but none have prevailed. My latest script which I devised is shown below, and is simply placed within a transparent brick:
game.Players.LocalPlayer.onTouch(function(player) player.CameraMode = Enum.CameraMode.LockFirstPerson end)
- VIShark15 |
|
|
| Report Abuse |
|
|
BlupoV2
|
  |
| Joined: 12 Nov 2012 |
| Total Posts: 543 |
|
|
| 29 Apr 2017 08:43 AM |
> game.Players.LocalPlayer
You're trying to connect the Touched event to the brick, not the Player (also, Players don't have a Touched event). Since you said the script is parented to the brick, you should change it to script.Parent.
> onTouch
http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched http://wiki.roblox.com/index.php?title=RBXScriptSignal#Connect
It's Touched. Also, you have to connect the event so it would be Touched:Connect().
(If you want to be technical, calling Touched returns a RBXScriptSignal, or Event, and calling Connect on the RBXScriptSignal runs whatever function you pass to it.)
> function(player)
The Touched event fires with a BasePart, not a Player. To get the player, you would need to use game.Players:GetPlayerFromCharacter() on the BasePart's parent.
http://wiki.roblox.com/index.php?title=API:Class/Players/GetPlayerFromCharacter
script.Parent.Touched:Connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) end)
(You should also check to see if the player actually exists.)
script.Parent.Touched:Connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if player then -- Code end end) |
|
|
| Report Abuse |
|
|
BlupoV2
|
  |
| Joined: 12 Nov 2012 |
| Total Posts: 543 |
|
|
| 29 Apr 2017 08:46 AM |
"calling Touched"
I meant "indexing Touched". |
|
|
| Report Abuse |
|
|
Plutoeros
|
  |
| Joined: 13 Feb 2016 |
| Total Posts: 214 |
|
|
| 29 Apr 2017 09:28 AM |
Thanks a lot, got it to work, maybe I should look at the wiki more .-.
- VIShark15 |
|
|
| Report Abuse |
|
|