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: Remote events

Previous Thread :: Next Thread 
Railmints is not online. Railmints
Joined: 11 Aug 2014
Total Posts: 272
01 Sep 2016 12:32 PM
Right now i am trying to master remote events, and so i am developing a script where when you click on a part, its color changes to yellow. However, i do not know how to translate this script---

script.Parent.Activated:connect(function()
if mouse.Target.ClassName == "Part" then
mouse.Target.BrickColor = BrickColor.new(255, 255, 0)
print(mouse.Target)
end
end)

from a local script to a regular script. How do i get the regular script to know what part was clicked on by the mouse?
Report Abuse
Afro_Sub is not online. Afro_Sub
Joined: 16 Jun 2013
Total Posts: 1114
01 Sep 2016 12:36 PM
Remake it


Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
01 Sep 2016 12:36 PM
RemoteEvent:FireServer(mouse.Target)

In your ServerScript:

RemoteEvent.OnServerEvent:connect(function(player, MouseTarget)
-- code
end)

Do you need a further explanation?
Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
01 Sep 2016 12:37 PM
It's a bit different for server to client.
Report Abuse
Railmints is not online. Railmints
Joined: 11 Aug 2014
Total Posts: 272
01 Sep 2016 12:47 PM
I get it now. You set mouse.Target as a parameter in the local script so the server script knows the value. Thats what i was struggling with, thanks! :)
Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
01 Sep 2016 12:52 PM
Here's how it's like for server to client:

Server-
RemoteEvent:FireClient(player, stuff)

Client-
RemoteEvent.OnClientEvent:connect(function(stuff)
Report Abuse
Railmints is not online. Railmints
Joined: 11 Aug 2014
Total Posts: 272
01 Sep 2016 12:54 PM
The final scripts i have are here

Local script(inside of a tool)--

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

script.Parent.Activated:connect(function()
game.Workspace.color:FireServer(mouse.Target)
end)

Server script(inside of workspace)

game.Workspace.color.OnServerEvent:connect(function(player, MouseTarget)
if MouseTarget.ClassName == "Part" then
MouseTarget.BrickColor = BrickColor.new(255,255,0)
end
end)

The Remote Event is named color and is also located inside of workspace
Report Abuse
Railmints is not online. Railmints
Joined: 11 Aug 2014
Total Posts: 272
01 Sep 2016 12:56 PM
Im wondering, would it be possible to communicate between client scripts as well?
Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
01 Sep 2016 01:16 PM
I don't know if you're supposed to use them like this, but I think this is what BindableEvents/Functions are for.
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