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: Unable to cast string to int?

Previous Thread :: Next Thread 
iWindowz is not online. iWindowz
Joined: 05 Jan 2013
Total Posts: 1809
22 Aug 2015 08:17 AM
This is the error;
prntscr.com/87l2o7
I used an inserted ModuleScript to run the function. This is the function's code;

function MainModule.Play()
local pr = "rbxassetid://"
local sp = script.Parent.MusicPlayer
sp.Parent.Music:Stop()
wait()
sp.Parent.Music.SoundId = pr..sp.ID.Text
local info = game:GetService("MarketplaceService"):GetProductInfo(sp.ID.Text)
sp.MusicName.Text = info.Name
sp.Parent.Music:Play()
print("smartPlayer Compact | Now Playing: "..info.Name)
end

^^ That code is called in a "Main" script.
This is how the Main script calls:

script.Parent.MusicPlayer.play.MouseButton1Down:connect(function() -- Runs play function
MainModule.Play()
end)

Anyone get it? It's odd. The parent of the ModuleScript is in the same directory as the Main script.

If needed, this is the code that changes the parent of the module script;

function MainModule.Transform()
script.Parent = game.Workspace.MusicPlayerInsert["smartTech Music Player"]
end

It is called in the Main script, just after inserting it using require(id)


local x = Instance.new("Siggy") x.Parent = roblox.Forums x.Text = "oh hi there"
Report Abuse
awotn is not online. awotn
Joined: 01 Nov 2014
Total Posts: 226
22 Aug 2015 08:18 AM
Play() is a method, so try naming the Play function something else.
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
22 Aug 2015 08:39 AM
Right here, you are casting a string to a function:
local info = game:GetService("MarketplaceService"):GetProductInfo(sp.ID.Text)

BUT, that function does not allow a string as an argument. Try using tonumber:
local info = game:GetService("MarketplaceService"):GetProductInfo(tonumber(sp.ID.Text))
Report Abuse
iWindowz is not online. iWindowz
Joined: 05 Jan 2013
Total Posts: 1809
22 Aug 2015 11:53 AM
After applying the 2 methods you gave me it still doesn't work.
Confused..


local x = Instance.new("Siggy") x.Parent = roblox.Forums x.Text = "oh hi there"
Report Abuse
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
22 Aug 2015 11:55 AM
You just posted a huge wall of unindented code and expect us to fix it? At least tell us what line the error is on.
Report Abuse
iWindowz is not online. iWindowz
Joined: 05 Jan 2013
Total Posts: 1809
22 Aug 2015 11:55 AM
Cough, view the screenshot
cough


local x = Instance.new("Siggy") x.Parent = roblox.Forums x.Text = "oh hi there"
Report Abuse
iWindowz is not online. iWindowz
Joined: 05 Jan 2013
Total Posts: 1809
22 Aug 2015 11:56 AM
The error is somewhere in this code:
function MainModule.Play()
local pr = "rbxassetid://"
local sp = script.Parent.MusicPlayer
sp.Parent.Music:Stop()
wait()
sp.Parent.Music.SoundId = pr..sp.ID.Text
local info = game:GetService("MarketplaceService"):GetProductInfo(sp.ID.Text)
sp.MusicName.Text = info.Name
sp.Parent.Music:Play()
print("smartPlayer Compact | Now Playing: "..info.Name)
end
Though, I can't identify where.


local x = Instance.new("Siggy") x.Parent = roblox.Forums x.Text = "oh hi there"
Report Abuse
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
22 Aug 2015 11:57 AM
How about you put a comment by the line the error is on?
Report Abuse
iWindowz is not online. iWindowz
Joined: 05 Jan 2013
Total Posts: 1809
22 Aug 2015 11:58 AM
As this is a localscript, the error appears from the script calling it, which is the Main script. It only shows the line where the error is, and that of course is the line where the function is called.


local x = Instance.new("Siggy") x.Parent = roblox.Forums x.Text = "oh hi there"
Report Abuse
iWindowz is not online. iWindowz
Joined: 05 Jan 2013
Total Posts: 1809
22 Aug 2015 11:58 AM
I mean modulescript. Excuse me.


local x = Instance.new("Siggy") x.Parent = roblox.Forums x.Text = "oh hi there"
Report Abuse
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
22 Aug 2015 12:00 PM
That's not true, come back when you plan on actually telling us which line the error is on.
Report Abuse
iWindowz is not online. iWindowz
Joined: 05 Jan 2013
Total Posts: 1809
22 Aug 2015 12:03 PM
Proof.

click the play button connected to the broken function:
prntscr.com/87nbqm
look in the server log:
prntscr.com/87nc3r



local x = Instance.new("Siggy") x.Parent = roblox.Forums x.Text = "oh hi there"
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
22 Aug 2015 01:17 PM
bruh

function MainModule.Play()
local pr = "rbxassetid://"
local sp = script.Parent.MusicPlayer
sp.Parent.Music:Stop()
wait()
sp.Parent.Music.SoundId = pr..sp.ID.Text
local info = game:GetService("MarketplaceService"):GetProductInfo(tonumber(sp.ID.Text))
sp.MusicName.Text = info.Name
sp.Parent.Music:Play()
print("smartPlayer Compact | Now Playing: "..info.Name)
end
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
22 Aug 2015 01:19 PM
Your siggy bugs me.

Instance.new("Siggy", roblox.Forums).Text = "oh hi there"
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