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 » Club Houses » Let's Make a Deal
Home Search
 

Re: LocalPlayer error

Previous Thread :: Next Thread 
JUDESPENCE14 is not online. JUDESPENCE14
Joined: 03 May 2013
Total Posts: 32
15 Feb 2015 05:06 PM
Hi i've created a few scripts
and they only work in robloxstudio when i'm in a server they don't work!

:Script

Part = script.Parent
-- Click
Part.ClickDetector.MouseClick:connect(function(playerWhoClicked)
Hint = Instance.new("Hint",game.Players.LocalPlayer.PlayerGui)
Hint.Text = "Hey, I've just been Clicked!"
wait(3)
game.Players.LocalPlayer.PlayerGui:ClearAllChildren()
end)
-- Hover
Part.ClickDetector.MouseHoverEnter:connect(function()
Part.BrickColor = BrickColor.new("Dark stone grey")
end)
-- Leave
Part.ClickDetector.MouseHoverLeave:connect(function()
Part.BrickColor = BrickColor.new("Medium stone grey")
end)

Normal script or localplayer script it won't work!

this is really starting to annoy me

when i'm in a server and i'm on the Roblox Developer Console i get an error saying

Workspace.Part.Script:3: attempt to index field 'LocalPlayer' (a nil value)
Stack Begin
Script 'Workspace.Part.Script.', Line 3
Stack Begin

Can someone please help me?
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
15 Feb 2015 05:07 PM
...go die
Report Abuse
ZacAttackk is not online. ZacAttackk
Joined: 23 Mar 2010
Total Posts: 15481
15 Feb 2015 05:07 PM
Local player only works in localscripts not normal ones
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
15 Feb 2015 05:10 PM
LocalPlayer only works in LocalScripts; not ServerScripts
It will work in Studio because Studio runs locally

If you want to run it on all players in game, do something like this

function getPlayers(callback)
for i,v in pairs(game.Players:GetChildren()) do
callback(v)
end
end

getPlayers(function(LocalPlayer)
Hint = Instance.new("Hint",game.Players.LocalPlayer.PlayerGui)
end)

that will make a hint for everyone in game, if you want it specific to the clicker, use playerWhoClicked rather than LocalPlayer
Report Abuse
JUDESPENCE14 is not online. JUDESPENCE14
Joined: 03 May 2013
Total Posts: 32
15 Feb 2015 05:10 PM
I've already tried that it doesn't work!
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
15 Feb 2015 05:11 PM
Part = script.Parent
-- Click
Part.ClickDetector.MouseClick:connect(function(playerWhoClicked)
Hint = Instance.new("Hint",game.Players.playerWhoClicked.PlayerGui)
Hint.Text = "Hey, I've just been Clicked!"
wait(3)
game.Players.playerWhoClicked.PlayerGui:ClearAllChildren()
end)
-- Hover
Part.ClickDetector.MouseHoverEnter:connect(function()
Part.BrickColor = BrickColor.new("Dark stone grey")
end)
-- Leave
Part.ClickDetector.MouseHoverLeave:connect(function()
Part.BrickColor = BrickColor.new("Medium stone grey")
end)


that should work



-iJava
Report Abuse
JUDESPENCE14 is not online. JUDESPENCE14
Joined: 03 May 2013
Total Posts: 32
15 Feb 2015 05:11 PM
Not helping ._.
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
15 Feb 2015 05:11 PM
You could have said "Thanks but that isn't working"

If you're going to act snotty when I'm trying to help expect no more help from me


-iJava
Report Abuse
JUDESPENCE14 is not online. JUDESPENCE14
Joined: 03 May 2013
Total Posts: 32
15 Feb 2015 05:16 PM
I want the script to give a hint to be in the localplayers playergui not the whole server...

i have another script that isn't working

:Script

local Part = script.Parent
-- Click
Part.ClickDetector.MouseClick:connect(function()
game.Players.LocalPlayer.Character.Humanoid.Health = math.huge
game.Players.LocalPlayer.Character.Humanoid.MaxHealth = math.huge
end)
-- Hover
Part.ClickDetector.MouseHoverEnter:connect(function()
Part.BrickColor = BrickColor.new("Dark stone grey")
end)
-- Leave
Part.ClickDetector.MouseHoverLeave:connect(function()
Part.BrickColor = BrickColor.new("Medium stone grey")
end)

i only want the localplayer to be godded

i am a beginner scripter
Report Abuse
JUDESPENCE14 is not online. JUDESPENCE14
Joined: 03 May 2013
Total Posts: 32
15 Feb 2015 05:18 PM
i wasn't talking to you i was talking about AbstractMadness
he just wrote "go die"
and i said not helping
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
15 Feb 2015 05:52 PM
local Part = script.Parent
-- Click
Part.ClickDetector.MouseClick:connect(function(x)
game.Players.x.Character.Humanoid.Health = math.huge
game.Players.x.Character.Humanoid.MaxHealth = math.huge
end)
-- Hover
Part.ClickDetector.MouseHoverEnter:connect(function()
Part.BrickColor = BrickColor.new("Dark stone grey")
end)
-- Leave
Part.ClickDetector.MouseHoverLeave:connect(function()
Part.BrickColor = BrickColor.new("Medium stone grey")
end)
Report Abuse
JUDESPENCE14 is not online. JUDESPENCE14
Joined: 03 May 2013
Total Posts: 32
15 Feb 2015 06:04 PM
Widths, i appreciate the help and everything i'm still having trouble when i put it in a script it works in studio only (because it runs locally) when i put it in a local script it doesn't work at all not in studio nor servers D:
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
15 Feb 2015 06:05 PM
Are you putting this in a serverscript or a localscript??


-iJava
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
15 Feb 2015 06:06 PM
my bad had an error

local Part = script.Parent
Part.ClickDetector.MouseClick:connect(function(x)
x.Character.Humanoid.Health = math.huge
x.Character.Humanoid.MaxHealth = math.huge
end)
Part.ClickDetector.MouseHoverEnter:connect(function()
Part.BrickColor = BrickColor.new("Dark stone grey")
end)
Part.ClickDetector.MouseHoverLeave:connect(function()
Part.BrickColor = BrickColor.new("Medium stone grey")
end)



-iJava
Report Abuse
JUDESPENCE14 is not online. JUDESPENCE14
Joined: 03 May 2013
Total Posts: 32
15 Feb 2015 07:36 PM
i'm putting it in a localscript should i put it in a serverscript?
Report Abuse
WindDagger is not online. WindDagger
Joined: 01 Dec 2012
Total Posts: 520
15 Feb 2015 07:37 PM
fart c‎‎‎‎‎‎‎‎ock d‎‎‎‎‎‎‎‎‎‎‎‎‎ick in my ‎a‎‎‎‎ss haha
Report Abuse
JUDESPENCE14 is not online. JUDESPENCE14
Joined: 03 May 2013
Total Posts: 32
15 Feb 2015 07:43 PM
wow you are hilarious! ._.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Club Houses » Let's Make a Deal
   
 
   
  • 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