generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Super Minor Error For force feild gui (I have and output statment.......)

Previous Thread :: Next Thread 
guyman1 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. guyman1
Joined: 25 Mar 2009
Total Posts: 169
31 Jul 2011 05:03 PM
bump
Report Abuse
SDuke524 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. guyman1
Joined: 25 Mar 2009
Total Posts: 169
31 Jul 2011 05:18 PM
why? i need it
Report Abuse
SDuke524 is not online. 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 is not online. guyman1
Joined: 25 Mar 2009
Total Posts: 169
31 Jul 2011 05:22 PM
oh ok
Report Abuse
Spectrumz is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image