Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I have a script with no errors but it doesn't work? Player teleportation problems.

Asked by 6 years ago
Edited 6 years ago

Hello everyone, now my script has no errors in the output but I did use the print method.

After I have found out where the script wasn't working I didn't know how to fix it. Therefore, I request assistance from anyone who knows how to fix my current mistake.

A few notes before you continue:

Note 1: This is a Server Script Note 2: This script is placed in ServerScriptService

And now here's the script;

local teamForFirstGuy
local BlueSpawn = game.Workspace:WaitForChild('BlueTower').BlueSpawn
local RedSpawn = game.Workspace:WaitForChild('RedTower').RedSpawn

game.Players.PlayerAdded:connect(function(plr)
    print('Attempt 1')
    local Stats = Instance.new('Model')
    Stats.Name = 'PlrStats'
    Stats.Parent = plr
    print('attempt 2')
    local Team = Instance.new("StringValue")
    Team.Name = "Team"
    if teamForFirstGuy then
        Team.Value = teamForFirstGuy == "Blue" and "Red" or "Blue"
    else
        Team.Value = math.random() < .5 and "Blue" or "Red"
        teamForFirstGuy = Team.Value
    print('attempt 3')
end
    Team.Parent = Stats
    print('attempt 4')
    plr.CharacterAdded:Connect(function(char)
        print('attempt 5')
        if Team.Value == 'Red' then
        print('attempt 6')
            char.HumanoidRootPart.CFrame = BlueSpawn.CFrame
            print('attempt7')
        else 
        print('attempt 8')
            char.HumanoidRootPart.CFrame = RedSpawn.CFrame
    print('attempt 9')
        end
    end)
end)

Now here are some notes about the prints;

Prints: the prints only print up to Attempt 6 Note: The problem is probably where the char.HumanoidRootPart.CFrame = BlueSpawn.CFrame starts.

Thank you for any support or feedback.

This has been edited so now it doesn't print attempt 6 and 7 and I still don't get teleported

1 answer

Log in to vote
0
Answered by
XAXA 1569 Moderation Voter
6 years ago

At lines 26 and 30, you're trying to make a Vector3 with another Vector3 as input.

Vector3.new(BlueSpawn.Position)) is wrong. You can just use BlueSpawn.Position directly to make your CFrame.

0
char.HumanoidRootPart.CFrame = BlueSpawn.CFrame, It still doesn't teleport me BlackOrange3343 2676 — 6y
0
If this didn't answer your question, you should probably not select it as the answer. XAXA 1569 — 6y
Ad

Answer this question