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
 

This whole thing glitches(RemoteEvent problem?)

Previous Thread :: Next Thread 
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 09:09 AM
I am making a DJ GUI for a party place and I'm trying to figure out why it won't work and I think that the problem has to do with RemoteEvents.


Client Script:
--[[
DJ CONTROLLER SCRIPT:

Creator: Fishguy100
Date: 6/16/2016
Time: 1:42
Description: Handles the DJ GUI and adds functionality to it.
--]]

math.randomseed(tick()) -- Changing the randomizations seed

--\\ Services
local Lighting = game:GetService("Lighting")
local ReplicatedStorage = game:GetService("ReplicatedStorage");

--\\ Tables
local Songs = {
{398582633,"My House"};
{162555471,"Turn down for what"};
{142376088,"Raining Tacos"};
{213689483,"Honey I'm Good"};
{413885541,"This is what you came for"};
{342189621,"Cheap Thrills"};
};

--\\ The ScreenGui itself
local self = script.Parent;

--\\ The background frame that holds all buttons and such
local Base = self:WaitForChild("Base");

--\\ The CurrentSong frame and it's contents
local CurrentSong = Base:WaitForChild("CurrentSong");
local SongName = CurrentSong:WaitForChild("SongName");
local rAmbient = CurrentSong:WaitForChild("R");
local gAmbient = CurrentSong:WaitForChild("G");
local bAmbient = CurrentSong:WaitForChild("B");

--\\ Time Stuff
local TimeLeftBar = Base:WaitForChild("TimeLeftBar");
local Bar = TimeLeftBar:WaitForChild("Bar");
local TimeElapsed = Base:WaitForChild("TimeElapsed");
local TotalTime = Base:WaitForChild("TotalTime");

--\\ RemoteEvents
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent");

--\\ Buttons
local StartButton = Base:WaitForChild("StartButton");

--\\ Value Holders
local LastSong

--\\ Functions
local function PickSong()
local C = Songs[math.random(1,#Songs)]
if C[1] ~= LastSong then
LastSong = C[1]
return C
else
return PickSong()
end
end

function SecondsToMinutes(seconds)
local SecondsLeft = seconds%60
local MinutesLeft = math.floor(seconds/60)
if SecondsLeft <= 0 then
SecondsLeft = "00"
elseif SecondsLeft <= 9 then
SecondsLeft = "0"..tostring(SecondsLeft)
else
SecondsLeft = tostring(SecondsLeft)
end
return tostring(MinutesLeft) .. ":" .. SecondsLeft
end

local function Cycle()

local ChosenSong = PickSong()

RemoteEvent:FireServer(ChosenSong[1])

wait(.5)

local Sound = workspace:FindFirstChild("Sound") and workspace:FindFirstChild("Sound").IsPlaying and workspace:FindFirstChild("Sound") or workspace:WaitForChild("Sound")



SongName.Text = ChosenSong[2]

Sound:Play()
wait(1)
local Length = math.floor(Sound.TimeLength)
TotalTime.Text = SecondsToMinutes(Length)

while Sound.IsPlaying do
local TimePlayed = math.floor(Sound.TimePosition)
TimeElapsed.Text = SecondsToMinutes(TimePlayed)
Bar.Size = UDim2.new(TimePlayed/Length,0,1,0)
wait()
end


Cycle()
end

--\\ Once start button is pressed
StartButton.MouseButton1Down:connect(function()
StartButton:Destroy()
Cycle()
end)


Server Script:

--\\ Services
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local Players = game:GetService("Players");

--\\ RemoteEvents
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent");

--\\ Binding to server events


RemoteEvent.OnServerEvent:connect(function(...)
local Table = {...}
local Sound = Instance.new("Sound",workspace)
Sound.SoundId = "http://www.roblox.com/asset/?id="..tonumber(Table[1])
Sound.Looped = false
Sound:Play()
spawn(function()
wait(Sound.TimeLength)
Sound:Stop()
Sound:Destroy()
end)
end)

And here's the error I get:
10:07:12.440 - ServerScriptService.Server:14: attempt to concatenate a nil value

How do I fix this?!





Report Abuse
John467583 is not online. John467583
Joined: 04 Mar 2010
Total Posts: 116
17 Jun 2016 09:36 AM
pretty sure the error has nothing to do with the remoteevents
the main thing causing the problem is that the "tonumber(Table[1])" part is nil, and you are concatenating it
Report Abuse
John467583 is not online. John467583
Joined: 04 Mar 2010
Total Posts: 116
17 Jun 2016 09:43 AM
ok, found a possible solution:
the OnServerEvent has 2 arguments: Player, and whatever else arguments you fired the server with (e.g a,b = 1,2 re:FireServer(a,b))
when you do this:

RemoteEvent.OnServerEvent:connect(function(...)
local Table = {...}

you are putting the first argument (player) into the table too. so player = table[1].

the corrected script is:

--\\ Services
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local Players = game:GetService("Players");

--\\ RemoteEvents
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent");

--\\ Binding to server events


RemoteEvent.OnServerEvent:connect(function(p,...) -- you can also remove p and replace "Table[1]" with "Table[2]"
local Table = {...}
local Sound = Instance.new("Sound",workspace)
Sound.SoundId = "http://www.roblox.com/asset/?id="..tonumber(Table[1])
Sound.Looped = false
Sound:Play()
spawn(function()
wait(Sound.TimeLength)
Sound:Stop()
Sound:Destroy()
end)
end)
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 10:15 AM
Either way, it still doesn't work.


Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 04:01 PM
BUMP


Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 04:16 PM
BUMP 2 PLEASE HELP


Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 04:20 PM
BUMP 3 I BEG YOU


Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 04:22 PM
BUMP 4 NEVER THOUGHT I'D GET THIS FAR...


Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 04:25 PM
BUMP 6 HELLLLPPPPP


Report Abuse
expoundings is online. expoundings
Joined: 02 Feb 2013
Total Posts: 2359
17 Jun 2016 04:28 PM
what happened to bump 5


Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 04:28 PM
I WONT STOP BUMPING UNTIL I GET AN ANSWER SO...
BUMP 7 HOPEFULLY LEADS TO HEAVEN


Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 04:29 PM
BUMP 8
IF I DONT GET AN ANSWER ILL WANT TO JUMP A GATE


Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 04:31 PM
BUMP 9

IM GONNA WHINE


Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
17 Jun 2016 04:36 PM
BUMP 10 DONT OFFEND


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