|
| 18 Sep 2015 06:38 PM |
Error = Workspace.Script:51: bad argument #3 to 'CFrame' (CFrame expected, got Object)
Looked on the wiki for that error and didn't find a possible fix to it.
Here's the script: local DEBUG = true -- Set this to true if you want all sorts of fancy debugging prints to see where this script stops working function debug(...) if DEBUG then print(...) end end
local Stages = { [0] = "0"; [1] = "1"; [2] = "2"; [3] = "3"; [4] = "4"; [5] = "5"; [6] = "6"; [7] = "7"; [8] = "8"; [9] = "9"; [10] = "10"; [11] = "11"; [12] = "12"; }
local StageBricks = game.Workspace:FindFirstChild("Stage Bricks")
for i,v in pairs(Stages) do local Spawn = StageBricks:FindFirstChild(v) if Spawn then print("Found "..v) Stages[i] = CFrame.new(Spawn.Position + Vector3.new(0, 3, 0)) else error('"'..v..'" not found in '..StageBricks:GetFullName()..'!') end end
game:GetService("Players").PlayerAdded:connect(function(Player) local PlayerName = Player.Name local leaderstats = Instance.new("IntValue", Player) leaderstats.Name = "leaderstats" local stage = Instance.new("IntValue", leaderstats) stage.Name = "Stage" stage.Value = 0 Player.CharacterAdded:connect(function(character) if character then print("Found "..PlayerName.."'s Character") local StageCFrame = StageBricks[stage.Value] if StageCFrame then local Torso = character:FindFirstChild("Torso") if Torso then debug("Found "..PlayerName.."'s Torso") Torso.CFrame = StageCFrame end end end end) end) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Sep 2015 06:38 PM |
= StageCFrame.CFrame
try that |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 06:39 PM |
| No output, now it just prints that it finds the torso and character but doesn't teleport me to the stage number. |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 06:43 PM |
if StageCFrame ~= nil then
You have to directly state that you want something not equal to nil. What you're currently doing only works for Booleans |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 Sep 2015 06:45 PM |
| Line eleven according to the post. |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 06:45 PM |
Yes (If that is the one where you teleport the player)
And keep that in mind for the rest of the script |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 06:46 PM |
| Just help me out, I've been trying to fix this script for FIVE days now and it's starting to get really irritating because everybody is just telling me to fix it myself when I literally can't. |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 06:48 PM |
| I am helping? what you mean? |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 06:49 PM |
| I mean, I'm getting tired of people telling me to put in stuff and it never comes out how I want it. |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 06:53 PM |
For instance, people are seriously over complicating this script when I've seen it done in 20 lines or less in a simple function.
|
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 06:55 PM |
| Want me to (re)make one for you? |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 06:56 PM |
| I'm remaking one right now, but if it doesn't work, you can fix my new one because I'm making it a lot simpler. |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 Sep 2015 07:02 PM |
Something like this right here, if you can't fix this one, I plead you to make a new one because this has taken me almost a week to figure out.
function CreateStats(Player) local leaderstats = Instance.new("IntValue", Player) leaderstats.Name = "leaderstats" local Stage = Instance.new("IntValue", leaderstats) Stage.Name = "Stage" Stage.Value = 0 end
local StageBricks = game.Workspace["Stage Bricks"]
function TeleportPlayer(plr) for i,v in pairs(StageBricks:GetChildren()) do local StageNumber = v:FindFirstChild(plr.leaderstats.Stage.Value) if StageNumber then print(""..StageNumber) local Torso = plr.Parent:FindFirstChild("Torso") if Torso then print("Found Torso") Torso.CFrame = StageNumber.CFrame end end end end
game.Players.PlayerAdded:connect(CreateStats) game.Players.PlayerAdded:connect(TeleportPlayer) |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 07:17 PM |
Fixed it :)
You're welcome. My edit's do not improve efficiency or anything else. I simply fixed the problem you were having
function CreateStats(Player) local leaderstats = Instance.new("IntValue", Player) leaderstats.Name = "leaderstats" local Stage = Instance.new("IntValue", leaderstats) Stage.Name = "Stage" Stage.Value = 0 end
local StageBricks = game.Workspace["Stage Bricks"]
function TeleportPlayer(plr) for i,v in pairs(StageBricks:GetChildren()) do plr:WaitForChild("leaderstats") local StageNumber = plr.leaderstats.Stage.Value if StageNumber ~= nil then if v.Name == tostring(StageNumber) then local Stage = v local Torso = plr.Character:FindFirstChild("Torso") if Torso ~= nil then print("Found Torso") Torso.CFrame = Stage.CFrame end end end end end
game.Players.PlayerAdded:connect(CreateStats) game.Players.PlayerAdded:connect(TeleportPlayer) |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 07:21 PM |
| Didn't work.. Unable to index the character. |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 07:22 PM |
q.q
Wait for the character. |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 07:24 PM |
| I did that and it didn't even teleport the player. About to give up on my game since I can't seem to find a single person that can fix my problem, just fix the script that I posted because that one has very little wrong with it. |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 07:25 PM |
It worked on my end when I had bricks in?
I really need to see how your game is laid out than... |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 Sep 2015 07:28 PM |
That's strange.
My workspace is setup exactly as is. I even tested it in Test Server (Which replicates online server). It seemed to work for me. |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 Sep 2015 07:31 PM |
It works once and then stops working.
So that means i need to use ChildAdded instead? |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2015 07:32 PM |
| Well I should mention my script was in ServerScriptService, however, that shouldn't matter. I'm utterly stumped why that is. |
|
|
| Report Abuse |
|
|