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 » Scripting Helpers
Home Search
 

Re: Player:GetMouse() Only works in Play Solo

Previous Thread :: Next Thread 
blueboy112 is not online. blueboy112
Joined: 15 Apr 2009
Total Posts: 802
28 Jan 2014 01:36 PM
Basically the title. Mouse comes up as nil in Online. (Remote Error Monitor System told me this.)
But in Play Solo, it actually gets the player's mouse.

This is in a normal script.

Script below;
----------

local Player = script.Parent.Parent.Parent.Parent
local Mouse = Player:GetMouse()

local Bar = script.Parent.Load.Bar
local CloseB = script.Parent.CloseButton
local Label = script.Parent.Label
local Jail = script.Parent.Jail.Value

Sound = 1
SoundFileA = script:FindFirstChild("BangDoor")
SoundFileB = script:FindFirstChild("DoorBreak")
Game:GetService("ContentProvider"):Preload(SoundFileA.SoundId)
Game:GetService("ContentProvider"):Preload(SoundFileB.SoundId)


Holding = false
Percent = 0

function Close()
if script and script.Parent and script.Parent.Parent then
script.Parent.Parent:remove()
end
end

CloseB.MouseButton1Down:connect(function ()
Holding = false
Close()
end)

function BreakBars()
if Jail then
local Bars = Jail:GetChildren()
for i = 1, #Bars do
if Bars[i].Name == "PrisonBar" then
Bars[i].Transparency = 1
Bars[i].CanCollide = false
end
end
if SoundFileB then
SoundFileB:Play()
end
Jail.Open.Value = true
end
end


Label.MouseButton1Down:connect(function()
Holding = true
end)

Label.MouseButton1Up:connect(function()
Holding = false
end)

Mouse.KeyDown:connect(function (k)
if k == "v" then
Holding = true
end
end)

Mouse.KeyUp:connect(function (k)
if k == "v" then
Holding = false
end
end)

Jail.Open.Changed:connect(function()
if Jail.Open.Value == true then
Close()
end
end)

while true do
wait()
if Jail and (Jail.Trigger.Position - Player.Character["Torso"].Position).magnitude < 12
and Jail:FindFirstChild("Open").Value == false then
if Holding then
Percent = Percent + 1
Bar.Size = UDim2.new(1,0,0,(-(2*Percent)))
wait(.045)
if Percent >= 100 then
BreakBars()
break
end
Sound = Sound + 1
if Sound == 16 and SoundFileA then
Sound = 1
SoundFileA:Play()
end
else
if Percent - 1 >= 0 then
Percent = Percent - 1
Bar.Size = UDim2.new(1,0,0,(-(2*Percent)))
wait(.15)
end
end
else
Close()
break
end
end

>> Schrödinger's cat walks into a bar. And doesn't.
Report Abuse
truefire2 is not online. truefire2
Joined: 04 Jul 2010
Total Posts: 5330
28 Jan 2014 01:44 PM
For local player, instead of script.Parent.Parent.Parent etc...
Use game.Players.LocalPlayer

Try it in a local script?
Report Abuse
blueboy112 is not online. blueboy112
Joined: 15 Apr 2009
Total Posts: 802
28 Jan 2014 01:57 PM
Hey it works! Thanks!

>> Schrödinger's cat walks into a bar. And doesn't.
Report Abuse
coolali333 is not online. coolali333
Joined: 18 Apr 2012
Total Posts: 300
28 Jan 2014 02:04 PM
Noticed the same thing.
Report Abuse
duckwit is not online. duckwit
Joined: 08 Aug 2008
Total Posts: 1310
28 Jan 2014 02:11 PM
Also, you may need to do:
while not player:GetMouse() do wait() end

It might be dangerous in some instances to assume that you already have access to the mouse.
Report Abuse
blueboy112 is not online. blueboy112
Joined: 15 Apr 2009
Total Posts: 802
28 Jan 2014 02:16 PM
The script it part of a GUI that is given to the player after the Character has loaded and walked into a trigger right by the spawn.
Does it still need to wait() for the player:GetMouse()?

>> Schrödinger's cat walks into a bar. And doesn't.
Report Abuse
duckwit is not online. duckwit
Joined: 08 Aug 2008
Total Posts: 1310
28 Jan 2014 02:20 PM
Probably not, no. You'd only need to wait if you needed access to the mouse as soon as the player had loaded. :)
Report Abuse
coolali333 is not online. coolali333
Joined: 18 Apr 2012
Total Posts: 300
28 Jan 2014 02:26 PM
@duck. I didn't notice that. Where did you find it?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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