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: Heartbeat / Renderstepped problem.

Previous Thread :: Next Thread 
Inigo18 is not online. 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
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
17 Dec 2016 04:50 PM
script pls
Report Abuse
Inigo18 is not online. 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 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
17 Dec 2016 05:04 PM
bumpp


Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
17 Dec 2016 05:08 PM
guyys :(


Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
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 is not online. 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
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
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 is not online. 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 is not online. 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
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
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 is not online. 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 is not online. 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 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
17 Dec 2016 05:28 PM
buump


Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
17 Dec 2016 05:33 PM
bumpp :(


Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
17 Dec 2016 05:38 PM
please guys


Report Abuse
Xstarlight is not online. Xstarlight
Joined: 18 Oct 2012
Total Posts: 870
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 is not online. 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
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