|
| 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 |
|
|
| |
|
|
| 15 Feb 2015 05:07 PM |
| Local player only works in localscripts not normal ones |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 15 Feb 2015 05:10 PM |
| I've already tried that it doesn't work! |
|
|
| Report Abuse |
|
|
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 |
|
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 15 Feb 2015 07:36 PM |
| i'm putting it in a localscript should i put it in a serverscript? |
|
|
| Report Abuse |
|
|
|
| 15 Feb 2015 07:37 PM |
| fart cock dick in my ass haha |
|
|
| Report Abuse |
|
|
|
| 15 Feb 2015 07:43 PM |
| wow you are hilarious! ._. |
|
|
| Report Abuse |
|
|