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 » Game Design
Home Search
 

Re: Using a RemoteEvent to change CurrentCamera?

Previous Thread :: Next Thread 
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
01 Dec 2014 08:22 PM
I'm not entirely sure how to even ask the question properly.
Suffice it to say that I need to use a server Script to change the CameraSubject and CameraType for a player.

I would think using a RemoteEvent would do the trick, but how do I go about doing it?
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
01 Dec 2014 08:44 PM
I suppose instead of cloning I could have a LocalScript that spawns with the player containing a function in an OnClientEvent event to handle the camera changing.
If I'm correct, the Backpack and PlayerGui are created when the character is loaded, so removing the character should't make it disappear.
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
01 Dec 2014 09:00 PM
you are correct, but what does removing the character have to do with camera manipulation?
I guess there's the subject
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
01 Dec 2014 09:30 PM
What I'm trying to is:

The player touches a brick, the Script in the brick sends a signal to the RemoteEvent in ReplicatedStorage, which then sends a signal back to the client into a LocalScript that will spawn with the player.

The player's character is then removed and his CurrentCamera is switched to a newly spawned spaceship of which the player will then control instead.
CameraSubject must be switched to the ship's hull.

I have no trouble at all with the functions do do either of those things but the RemoteEvent is just plain confusing.

I "THINK" that the Script would use FireClient, and then the LocalScript listens with OnClientEvent
-------------------------------------------
The script in the brick (idc if it's not efficient, the point of this post is not the script but the RemoteEvent communication)


--The Server Script
Debounce = false
script.Parent.Touched:connect(function(hit)
if Debounce == false then Debounce = true
local H = hit.Parent:findFirstChild("Humanoid")
if H then local P = game.Players:GetPlayerFromCharacter(hit.Parent)
if P then game.ReplicatedStorage.RemoteCamera:FireClient(P)
end end end wait(1) end)

--The Local Script
game.ReplicatedStorage.RemoteCamera.OnClientEvent:connect(function(P)
P.Character.Humanoid.Health = 50
end)



I got an error in the dev console for the Local Script saying P was either not defined or was nil. I don't remember now.

The point is, it's not connecting properly.
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
02 Dec 2014 11:48 AM
bump
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
02 Dec 2014 12:01 PM
game.ReplicatedStorage.RemoteCamera.OnClientEvent:connect(function(P)
P.Character.Humanoid.Health = 50
end)


Alright, P is nil. When you give the Player object argument for FireClient, that argument isn't transferred to OnClientEvent.

Instead

game.ReplicatedStorage.RemoteCamera.OnClientEvent:connect(function()
game.Players.LocalPlayer.Character.Humanoid.Health = 50
end)
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
02 Dec 2014 12:54 PM
If it's not transferred then what is stopping that same function from executing when someone else fires it?
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
02 Dec 2014 04:49 PM
im sure your fix works but i still need an answer.
if the variables don'ty transfer over then what's stopping the function from firing when someone else invokes it?
Report Abuse
IthacaMedia is not online. IthacaMedia
Joined: 25 Jan 2014
Total Posts: 1337
02 Dec 2014 06:23 PM
Because when you call :FireClient(player), you are firing the event only for that player, so unless you call :FireAllClients(), you will only fire for 1 client.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Dec 2014 06:31 PM
To make things more clear:

The FireClient method takes the first argument as the player, and the rest as the actual arguments.

So to do what you did, you would have to do:
FireClient(P, P)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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