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: FE problem

Previous Thread :: Next Thread 
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
11 Feb 2016 05:55 PM
server script:
game.Players.PlayerAdded:connect(function(player)
local Stage = game:GetService("ServerStorage").StatFolder:FindFirstChild(player.Name).Stage
print 'stage found'
NotifyUpdateStage:FireClient(Stage)
print 'fired from server'
Stage.Changed:connect(function()
NotifyUpdateStage:FireClient(Stage)
end)
end)



---------
local script:

local player = game.Players.LocalPlayer
local TotalStages = script.Parent.Parent.Parent:WaitForChild("Stages")
local NotifyStageUpdate = game:GetService("ReplicatedStorage"):WaitForChild("Remote"):WaitForChild("NotifyStageUpdate")

print 'progress bar loaded'

NotifyStageUpdate.OnClientEvent:connect(function(Stage)
print 'client event received'
Stage = Stage.Value
script.Parent.Size = UDim2.new(Stage / TotalStages.Value, 0, 1, 0)
script.Parent.StageLabel.Text = "STAGE "..Stage.Value.."/"..TotalStages.Value
end)

---------------
Stats are being stored in serverstorage like so:
ServerStorage>"StatHolder"Player1>Stage

Trying to update the player's progress bar when their Stage is changed.

It only prints 'progress bar loaded' but nothing else, even when the stage value is changed. What am I doing wrong?
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
11 Feb 2016 06:27 PM
so i changed FireServer's argument to FireServer(player, stage) and onclientevent's to player,stage as well but now i get an error saying Stage is a nil value
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
11 Feb 2016 06:34 PM
server script

game.Players.PlayerAdded:connect(function(player)
Stage = game:GetService("ServerStorage"):WaitForChild("StatFolder"):WaitForChild(player.Name).Stage
NotifyStageUpdate:FireClient(player, Stage) --// needs to set progress bar when player first joins
print 'fired from server'
Stage.Changed:connect(function()
NotifyStageUpdate:FireClient(player, Stage) --// update progess bar when stage is updated
print 'fired from server'
end)
end)

local script

local player = game.Players.LocalPlayer
local TotalStages = script.Parent.Parent.Parent:WaitForChild("Stages")
local NotifyStageUpdate = game:GetService("ReplicatedStorage"):WaitForChild("Remote"):WaitForChild("NotifyStageUpdate")

print 'progress bar loaded'

NotifyStageUpdate.OnClientEvent:connect(function(player, Stage)
print 'client event received'
script.Parent.Size = UDim2.new(Stage.Value / TotalStages.Value, 0, 1, 0)
script.Parent.StageLabel.Text = "STAGE "..Stage.Value.."/"..TotalStages.Value
end)


-------
it's printing everything but throwing an error on this line saying stage is a nil value

script.Parent.Size = UDim2.new(Stage.Value / TotalStages.Value, 0, 1, 0)

helppp
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
11 Feb 2016 06:44 PM
--server script

local notify = game.ReplicatedStorage:WaitForChild("StageUpdate")
local stats = game.ServerStorage.StatFolder

game.Players.PlayerAdded:connect(function(player)
local stage = stats[player.Name].Stage
notify:FireClient(player, stage.Value)
stage.Changed:connect(function()
notify:FireClient(player, stage.Value)
end)
end)

--local script

local player = game.Players.LocalPlayer
local stage = script.Parent.Parent.Parent:WaitForChild("Stage")
local notify = game.ReplicatedStorage:WaitForChild("StageUpdate")

notify.OnClientEvent:connect(function(player, val)
script.Parent.Size = UDim2.new(val / stage.Value, 0, 1, 0)
script.Parent.StageLabel.Text = "STAGE "..val.."/"..stage.Value
end)
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
11 Feb 2016 07:00 PM
had to edit your code a bit to make it fit but it still says that 'val' is a nil value..i know its there
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
11 Feb 2016 07:24 PM
aaaaa bump
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
11 Feb 2016 07:40 PM
it loads on the server but when i use it as an arg in fireserver it says it's nil


whyyyy
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
11 Feb 2016 08:01 PM
bump...
Report Abuse
gangman67 is not online. gangman67
Joined: 04 Jun 2011
Total Posts: 798
11 Feb 2016 08:06 PM
If your using his code I belive that the value is being passed as the player parameter, in the local script "notify.OnClientEvent:connect(function(player, val)", player shouldnt be a parameter
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
11 Feb 2016 08:28 PM
Player has to be passed in FireServer so it needs to be received in OnClientEvent right?
Report Abuse
gangman67 is not online. gangman67
Joined: 04 Jun 2011
Total Posts: 798
11 Feb 2016 08:33 PM
When the server is firing to the client you need a player, but on the clients end the player isn't a parameter
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
11 Feb 2016 09:29 PM
I removed the player arg, same error
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
11 Feb 2016 10:41 PM
b
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
12 Feb 2016 07:42 AM
;-;
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
12 Feb 2016 08:14 AM
Tried having the stats and the remote event in workspace and same error
Report Abuse
Vladimir301 is not online. Vladimir301
Joined: 19 Dec 2013
Total Posts: 644
12 Feb 2016 08:30 AM
I'll try some things in Studio
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
12 Feb 2016 08:31 AM
ok thx...
Report Abuse
Tigerism is not online. Tigerism
Joined: 26 Aug 2015
Total Posts: 561
12 Feb 2016 08:40 AM
u can't pass objects in an argument via remoteevents or remotefunctions
Report Abuse
Vladimir301 is not online. Vladimir301
Joined: 19 Dec 2013
Total Posts: 644
12 Feb 2016 08:42 AM
if val is returning nil are you sure you have it all in the same spelling that's only reason I can imagine it's returning nil right now.
Report Abuse
Tigerism is not online. Tigerism
Joined: 26 Aug 2015
Total Posts: 561
12 Feb 2016 08:43 AM
you need to pass the actual stage value, not the object itself

so Stage.Value
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
12 Feb 2016 08:44 AM
@Tiger
Just tried that

"attempt to perform arithmetic on local 'Stage' (a nil value)"
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
12 Feb 2016 08:46 AM
NotifyStageUpdate.OnClientEvent:connect(function(player, Stage)
print 'client event received'
local size = Stage / TotalStages.Value
script.Parent.Parent.Size = UDim2.new(size, 0, 1, 0)
script.Parent.Text = "STAGE "..Stage.."/"..TotalStages.Value
end)

on this line:
local size = Stage / TotalStages.Value

I couldn't put "Stage.Value" in here
Report Abuse
Tigerism is not online. Tigerism
Joined: 26 Aug 2015
Total Posts: 561
12 Feb 2016 08:47 AM
use tonumber on the math part and make sure an actual value is inside Stage. so like put

if not Stage then return end

to stop the rest of the script if the value isn't even there

also do print(Stage) on the local script part to see what's even being sent
Report Abuse
Tigerism is not online. Tigerism
Joined: 26 Aug 2015
Total Posts: 561
12 Feb 2016 08:49 AM
paste your new script plz
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
12 Feb 2016 08:50 AM
print(Stage)
local size = tonumber(Stage) / TotalStages.Value

Printed nil...
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