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

What's wrong with my scripts?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I have some scripts that transport people to a specific spawn, one is for owners, one is for the owners friends. I have tried to fix them myself, but, I just made it worse...well, here they are.

Owner:

Name = "titan111" --player(s) to spawn at this spawn
Spawn = "OwnerSpawn321" --The spawns name
spwn = game.Workspace:FindFirstChild(Spawn) --find the spawn

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        wait(1) 
        if char.Name:lower() == Name:lower() then
            char.Torso.CFrame = CFrame.new(spwn.Position+Vector3.new(0,5,0))
        end
    end)
end)

Friends:

local spawn = Script.Parent

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(char)
            if player:IsFriendsWith(12345678) then--12345678 is the User ID
            char:MoveTo(spawn.Position)
        end
    end)
end)

It would really help me if you could fix these up, i'm not very good at scripting, anyone know easy lessons on how I can learn Lua? I've tried the ROBLOX wiki, they are to hard for me.

0
What exactly do you think is wrong with them? Are there errors in the output? BlueTaslem 18071 — 10y
0
Well, I can't spawn. titan111 0 — 10y
0
... What does that mean? BlueTaslem 18071 — 10y
0
You don't spawn at all? That would mean the CharacterAdded-event isn't even called. Did you disable Players.CharacterAutoLoads? Try to add in a few prints to attempt to debug it. Post output-errors too. Ravenshield 180 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

Why not just do this?

local owner = --owner name here
local ownerSpawn = game.Workspace:FindFirstChild("OwnerSpawn321")
local friendSpawn = game.Workspace:FindFirstChild("FriendSpawn")

game.Players.ChildAdded:connect(function(player)
if player.Name:lower() == owner:lower() then
player.Character:MoveTo(Vector3.new(ownerSpawn.Position))
elseif player:IsFriendsWith(game.CreatorId) then
player.Character:MoveTo(Vector3.new(friendSpawn.Position))
end
end
end)

It would be something like that. Note that I just thought that up, I can't test it.

Ad

Answer this question