|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|