Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 17 Dec 2016 04:49 PM |
Hey! So I'm having this problem where I define a variable before a heartbeat function. Let's call it Player. Inside the function, I put print(Player). Player will be defined by a for loop, so it will change over loops, let's say in the first loop Player = "Player1" and in the second loop Player = "Player2" So the first loop, the print will only put Player1, however, in the second loop, it will both print Player1 and Player2. It's like if the function doesn't forget the variable Player from before it was changed, even if I put later on Player = nil. Any suggestions?
|
|
|
| Report Abuse |
|
|
| |
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 17 Dec 2016 04:53 PM |
SERVER SCRIPT:
for i = 1,#tableofplayers do workspace:WaitForChild("Remotes"):WaitForChild("TimeGoDown"):FireAllClients(tableofplayers[i]) wait(5) end
LOCAL SCRIPT:
Event.OnClientEvent:connect(function(Player) RunService.Heartbeat:connect(function() print(Player) -- here's the problemo cam.CFrame = CFrame.new(Player.Torso.Position + Vector3.new(0,10,25), Player.Torso.Position) end)
|
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
| |
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
| |
|
|
| 17 Dec 2016 05:10 PM |
what in the world are you trying to do
for i = 1,#tableofplayers do workspace:WaitForChild("Remotes"):WaitForChild("TimeGoDown"):FireClient(tableofplayers[i]) end
local Player = game.Players.LocalPlayer
Event.OnClientEvent:connect(function() RunService.Heartbeat:connect(function() cam.CFrame = CFrame.new(Player.Torso.Position + Vector3.new(0,10,25), Player.Torso.Position) end)
i'm not any more should not the panda and? |
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 17 Dec 2016 05:11 PM |
I'm trying to make the camera keep displaying the player in a certain position. Obviously that's not the full code, I deleted variables like cam so that it doesn't take up space.
|
|
|
| Report Abuse |
|
|
|
| 17 Dec 2016 05:12 PM |
you need to look over remoteevents again
when firing a remoteevent from the server to the client you pass through the player instance but don't receive it on the client
i'm not any more should not the panda and? |
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 17 Dec 2016 05:15 PM |
derp!! I deleted by error: Event.OnClientEvent:connect(function(Player) There's a Player arg inside the Event function, my bad.
|
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 17 Dec 2016 05:15 PM |
Wait, no I didn't. I don't get what you're trying to tell me, sorry
|
|
|
| Report Abuse |
|
|
|
| 17 Dec 2016 05:17 PM |
k
server script:
game.ReplicatedStorage.RemoteEvent:FireClient(game.Players.Inigo18, "what's up")
in local script:
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(string) print(string) end)
--> what's up
i'm not any more should not the panda and? |
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 17 Dec 2016 05:22 PM |
but the camera actually works and points to the player. the thing is that in the second loop, the camera will keep switching modelA - modelB - modelA etc.
|
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 17 Dec 2016 05:22 PM |
by the way i wanna thank you for helping me through this
|
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
| |
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
| |
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
| |
|
|
| 17 Dec 2016 06:17 PM |
If it keeps switching, either: 1. the loop hasn't stopped 2. the client is being over fired 3. the activation is messed up
Pls post the "new" code: |
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 17 Dec 2016 06:18 PM |
Never mind, I found out, thanks for everyone's help!
|
|
|
| Report Abuse |
|
|