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 » Scripters
Home Search
 

Re: What is wrong with this script

Previous Thread :: Next Thread 
nicebros is not online. nicebros
Joined: 17 Jun 2011
Total Posts: 102
31 Jul 2015 11:25 AM
while true do
wait(5)
players = game.Players.NumPlayers
games = game.ServerStorage.Games:GetChildren()
local player = game.Players.LocalPlayer
val = game.Workspace.Topval
local playen = game.Players.LocalPlayer.Name
local Playerw = game.Workspace:FindFirstChild(playen)

if players >= 1 then
wait(1)
rangame = math.random(1, #games)
minigamech = games[rangame]
minigamec = minigamech:Clone()
minigamec.Parent = game.Workspace
spawns = minigamec.Spawns:GetChildren()
for i, v in pairs(game.Players:GetChildren()) do
Pame = v.Name
checkName = game.Workspace:FindFirstChild(Pame)
if checkName then
checkHumanoid = checkName:FindFirstChild("Humanoid")
if checkHumanoid then
checkName:MoveTo(spawns[i].Position)
end
end
end
wait(2.2)
pie = game.Lighting.Winner:clone()
pie.Parent = Playerw

for i = 9, 6, -1 do
game.Workspace.Topval.Value = "Time Left "..i
wait(1)
end
if Playerw.Winner then
done = math.random(10,50)
player.stats.cash.Value=player.stats.cash.Value+(done)
for i = 5, 1, -1 do
game.Workspace.Topval.Value = "Time Left "..i
wait(1)
end
else

end
wait(7)
minigamec:remove()
end

end

it comes up with ServerScriptService.Script:11: attempt to index field 'LocalPlayer' (a nil value) and i tried putting it in a local script and that just broke the script, it only works on solo mode
Report Abuse
nicebros is not online. nicebros
Joined: 17 Jun 2011
Total Posts: 102
01 Aug 2015 03:39 AM
Bump
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
01 Aug 2015 03:49 AM
you can't get a "local player" in a server script. read up more on the difference between local and server scripts.

http://wiki.roblox.com/index.php?title=API:Class/LocalScript
http://wiki.roblox.com/index.php?title=API:Class/Script
Report Abuse
nicebros is not online. nicebros
Joined: 17 Jun 2011
Total Posts: 102
01 Aug 2015 03:57 AM
@instawin i know i cant use localplayer i was wondering how could i still get localplayer in a global script
Report Abuse
nicebros is not online. nicebros
Joined: 17 Jun 2011
Total Posts: 102
01 Aug 2015 07:33 AM
Bump, Someone help this isnt to advanced, is it?
Report Abuse
Clxver is not online. Clxver
Joined: 19 Oct 2014
Total Posts: 727
01 Aug 2015 08:21 AM
for _,v in pairs(game.Players:GetChildren()) do
--code
end

If not you, then who? If not now, then when?
Report Abuse
nicebros is not online. nicebros
Joined: 17 Jun 2011
Total Posts: 102
01 Aug 2015 08:24 AM
@Clxver would i just remove the player variable and put the code inside of the function
Report Abuse
nicebros is not online. nicebros
Joined: 17 Jun 2011
Total Posts: 102
01 Aug 2015 08:29 AM
not function loop sorry
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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