|
| 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
|
  |
| 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 |
|
|
|
| 28 Jan 2014 01:57 PM |
Hey it works! Thanks!
>> Schrödinger's cat walks into a bar. And doesn't. |
|
|
| Report Abuse |
|
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 28 Jan 2014 02:26 PM |
| @duck. I didn't notice that. Where did you find it? |
|
|
| Report Abuse |
|
|