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: Script works in-studio, but it doesn't work in-game!

Previous Thread :: Next Thread 
laczka is not online. laczka
Joined: 26 Jan 2015
Total Posts: 258
28 Aug 2016 08:17 PM
I am making coffee machines, the main local script for a client player is supposed to check when you clicked, and then get your local mouse.Target to determine if you really clicked the on/off button. And the thing is, it works immaculately in-studio testing mode, but when you go to play the actual game on your ROBLOX client (in-game) it does nothing! It seems as if it fails to check local mouse.Target when you are in-game. The game is filtering enabled, maybe that is my problem? Maybe I should use a remote function for this? did ROBLOX deprecate the mouse.Target method? I am completely stumped right now, if anyone could help me out I would really appreciate it. Here is the fundamental source code in the local script:
local r = game:GetService("ReplicatedStorage").RemoteEvent
local plr = game.Players.LocalPlayer
local m = plr:GetMouse()
local debounce = false
m.Button1Down:connect(function()
if debounce == false then
debounce = true
if (m.Target ~= nil and
m.Target.Name == "OnOff" and
m.Target.Parent:IsA("Model") and
_G.on == false) then
if (plr:IsInGroup(2906079) and
plr:GetRankInGroup(2906079) >= 4) then
r:FireServer(plr.Name.." 0x00")
end
end
debounce = false
end
end)

--[[Notes:
1:In case anyone is wondering, I checked if the on/off button's parent is a model because it resides within the coffeemachine model.
2:In case anyone is wondering why fired the server with plr.name and 0x00 in hexadecimal, it is because I decided to use a code to determine what function the server side coffee machine script would run upon being fired the clients name, the server script looks for an 0x00, 0x01, or an 0x02 to determine the global function that it will run.]]
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
28 Aug 2016 08:18 PM
because

m.Button1Down

use user input service
Report Abuse
laczka is not online. laczka
Joined: 26 Jan 2015
Total Posts: 258
28 Aug 2016 08:19 PM
thanks blarg I will try userInputService and see if it works.
Report Abuse
aagg11 is not online. aagg11
Joined: 11 Feb 2010
Total Posts: 487
28 Aug 2016 08:30 PM
Yeah that happend to me too and my friend got it working for me.
Report Abuse
laczka is not online. laczka
Joined: 26 Jan 2015
Total Posts: 258
28 Aug 2016 08:31 PM
my only question now is what event in userInputService can determine a mouse click.
Report Abuse
laczka is not online. laczka
Joined: 26 Jan 2015
Total Posts: 258
28 Aug 2016 08:44 PM
Nope, I am still having the same problem. I changed the local script mouse click event to:
local r = game:GetService("ReplicatedStorage").rev
local plr = game.Players.LocalPlayer
local m = plr:GetMouse()
local debounce = false
game:GetService("UserInputService").InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if debounce == false then
debounce = true
if (m.Target ~= nil and
m.Target.Name == "OnOff" and
m.Target.Parent:IsA("Model") and
_G.on == false) then
if (plr:IsInGroup(2906079) and
plr:GetRankInGroup(2906079) >= 4) then
r:FireServer(plr.Name.." 0x00")
end
end
debounce = false
end
end
end)
but it is still behaving the same way where is works perfectly in-studio, but it doesn't work at all in-game. Anymore help would be greatly appreciated.
Report Abuse
laczka is not online. laczka
Joined: 26 Jan 2015
Total Posts: 258
29 Aug 2016 04:25 PM
bump
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