of     1   

Valyrian_Advisor
#215580414Saturday, April 29, 2017 8:06 PM GMT

So... I have a script in the workspace which is this one: for i,v in pairs(game.Players:GetPlayers()) do TPevent:FireClient(v) end It just uses a remote event to tell a certain client (v) to start his function. The localscript is: local TPevent = game.ReplicatedStorage:WaitForChild("TP") local player = game.Players.LocalPlayer TPevent.OnClientEvent:Connect(function(player,changing) player.Character.Torso.Anchored = true player.Character.Torso.CFrame = workspace.Spawns[i].Spawn.CFrame wait(2) player.Character.Torso.Anchored = false end) The problem is that I can't actually use [i] because that was in the normal script when I didn't use the remove event... This script should teleport each player to a certain spawn which is called like a number, that's why I used the [i] of the for loop. What can I do to make it work as I want?
Valyrian_Advisor
#215581176Saturday, April 29, 2017 8:16 PM GMT

Please, I really need help.
DataStore
#215581516Saturday, April 29, 2017 8:21 PM GMT

Whilst the first argument passed is always the player to trigger, you can also pass along other arguments (as noted on the ROBLOX Wiki). local Spawns = Workspace.Spawns:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do TPevent:FireClient(v, Spawns[i].Spawn.CFrame) end local TPevent = game.ReplicatedStorage:WaitForChild("TP") local player = game.Players.LocalPlayer TPevent.OnClientEvent:Connect(function(player,location) player.Character.Torso.Anchored = true player.Character.Torso.CFrame = location wait(2) player.Character.Torso.Anchored = false end)
VilgO
#215581876Saturday, April 29, 2017 8:25 PM GMT

You haven't actually described what is it you want it to do, but I'll assume that there's a single spawn point for every player in the game, and you want to move the player to their spawn. "workspace.Spawns[i]" simply chooses which spawn point to use. You probably store somewhere the information about which spawn point belongs to which player, so you need to use that instead. I can't tell what exactly you need to do since I don't know anything about how you store that information. Maybe "workspace.Spawns" is a folder that uses player Ids as keys. In that case "workspace.Spawns[player.UserId]" should work. Also note that "i" in "TPevent.OnClientEvent:Connect" is not the same variable as the "i" in "for i,v in pairs..."
BJCarpenter
#215582893Saturday, April 29, 2017 8:39 PM GMT

You could pass I, but that defeats FE a little bit. for i,v in pairs(game.Players:GetPlayers()) do TPevent:FireClient(v,i) end It just uses a remote event to tell a certain client (v) to start his function. The localscript is: local TPevent = game.ReplicatedStorage:WaitForChild("TP") local player = game.Players.LocalPlayer TPevent.OnClientEvent:Connect(function(player,changing, i) player.Character.Torso.Anchored = true player.Character.Torso.CFrame = workspace.Spawns[i].Spawn.CFrame wait(2) player.Character.Torso.Anchored = false end)
Valyrian_Advisor
#215583216Saturday, April 29, 2017 8:44 PM GMT

I get this error: Character is not a valid member of CFrame
VilgO
#215584774Saturday, April 29, 2017 9:05 PM GMT

We are not psychics, tell us everything.

    of     1