guyman1
|
  |
| Joined: 25 Mar 2009 |
| Total Posts: 169 |
|
|
| 31 Jul 2011 04:45 PM |
I made this script, and here is what output said: "PlayerGui is not a valid member of DataModel"
function onTouch(hit) while true do if hit.Parent:findFirstChild("Humanoid") ~= nil then game.PlayerGui.ToggleForceFieldGui.Forcefield.Toggled.Value = 0 end end end
script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 31 Jul 2011 04:47 PM |
"game.PlayerGui"
PlayerGui isn't in game it's in the player. So to get the player you'll have to do this
function onTouch(hit)--don't need the while loop unless there was another reason for it? if hit.Parent:findFirstChild("Humanoid") then -- ~=nil does nothing local player=game.Players:GetPlayerFromCharacter(hit.Parent) -- gets the player if player then -- checks if there is a player player.PlayerGui.ToggleForceFieldGui.Forcefield.Toggled.Value = 0 end end end
script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
guyman1
|
  |
| Joined: 25 Mar 2009 |
| Total Posts: 169 |
|
|
| 31 Jul 2011 04:49 PM |
| oh. ok that makes sense thx a lot!! |
|
|
| Report Abuse |
|
|
guyman1
|
  |
| Joined: 25 Mar 2009 |
| Total Posts: 169 |
|
|
| 31 Jul 2011 04:55 PM |
well what if i want to do this:
function onTouch(hit) if hit.Parent:findFirstChild("Humanoid") then local player=game.Players:GetPlayerFromCharacter(hit.Parent) if player then player.PlayerGui.ToggleForceFieldGui.Forcefield.Toggled.Value = 0 Character.ForceField:Remove() end end end
script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
guyman1
|
  |
| Joined: 25 Mar 2009 |
| Total Posts: 169 |
|
| |
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 31 Jul 2011 05:04 PM |
player.Character.ForceField:Remove()
or you could easily do
hit.Parent.ForceField:remove() |
|
|
| Report Abuse |
|
|
guyman1
|
  |
| Joined: 25 Mar 2009 |
| Total Posts: 169 |
|
|
| 31 Jul 2011 05:10 PM |
would this work?
function onTouch(hit) while true do if hit.Parent:findFirstChild("Humanoid") then local player=game.Players:GetPlayerFromCharacter(hit.Parent) if player then player.PlayerGui.ToggleForceFieldGui.Forcefield.Toggled.Value = 0 player.Character.ForceField:Remove() end end end end
script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 31 Jul 2011 05:11 PM |
| test it and see. Also why is that while loop there? |
|
|
| Report Abuse |
|
|
guyman1
|
  |
| Joined: 25 Mar 2009 |
| Total Posts: 169 |
|
|
| 31 Jul 2011 05:15 PM |
| it does not work. also, it is there because i need it to continously turn the forcefield off any time i step on the brick |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 31 Jul 2011 05:16 PM |
| You don't need that, get rid of the while loop. |
|
|
| Report Abuse |
|
|
guyman1
|
  |
| Joined: 25 Mar 2009 |
| Total Posts: 169 |
|
| |
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 31 Jul 2011 05:19 PM |
| It'll do what you want without the while loop, the while loop in this situation will just break stuff. |
|
|
| Report Abuse |
|
|
guyman1
|
  |
| Joined: 25 Mar 2009 |
| Total Posts: 169 |
|
| |
|
Spectrumz
|
  |
| Joined: 22 Mar 2011 |
| Total Posts: 4338 |
|
|
| 31 Jul 2011 05:36 PM |
function onTouch(hit) if hit.Parent:findFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then player.PlayerGui.ToggleForceFieldGui.Forcefield.Toggled.Value = 0 hit.Parent.ForceField:Remove() end end end
script.Parent.Touched:connect(onTouch)
But y'know, it would be simpler if the 'Toggled' IntValue was a BoolValue. |
|
|
| Report Abuse |
|
|