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

How do I change the spawn point for everyone while at the same time re:ing them with a chat command?

Asked by 3 years ago

I'm sorry for the badly written title it's because I exceeded the character limit there so I had to try shortening it.

So my friend owns a group which is to train people for magic games on Roblox. I've helped him many times with stuff since he doesn't know how to script.

Now I just know the basics and nothing more and I'm trying to make a chat command to change the spawn point to another room and refreshing them so they get teleported there and respawns there, and one to also change the spawn point back.

What I've tried is that I've used a door opening script with a chat command but changed it up a bit, here's the code: (I did not make the original script I only edited it)

--// Main variables:
local Door = game.Workspace.Sword -- This is the sword place spawn point
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Main = game.Workspace.Main -- This is the meeting/main spawn point
--// Whitelist:
local LocalWhitelist = {
    --// Add people to the whitelist like this:
    --|| "UserName", or "UserId", alternatively: ["UserName"] = true, or ["UserId"] = true,
    [""] = true,
    [""] = true,
    [""] = true,
    [""] = true,
    [""] = true,
    [""] = true,
    ["docterwhodc55"] = true,
    ["TimmyTotten"] = true,
    [""] = true,
    [""] = true,
    [""] = true,
    [""] = true,
    [""] = true,
    [""] = true,
    [""] = true,
    [""] = true,
    [""]= true,
}
local UseGlobalWhitelist = false --// Use the whitelist stored in ServerScriptService
local AllowEveryoneInStudio = true
--// true: if run in studio everyone can use those commands (disable befor publishing)
--|| false: whitelist only even if in studio

local Fade = false
--// true: It will slowly fade away
--|| false: it will go away instantly

local Keywords = {
    ["Apparatus Swordus"] = "Apparatus Swordus", --// The word you need to type in chat to open the door (Case sensetive)
    ["Apparatus Meetum"] = "Apparatus Meetum", --// The word you need to type in chat to close the door (Case sensetive)
}

--// Core (Dont edit)
local Whitelist = {}
if UseGlobalWhitelist == true then
    Whitelist = require(game:GetService("ServerScriptService"):WaitForChild("GlobalWhitelist"))
else
    Whitelist = LocalWhitelist
end

function FindInTable(Table, Item) --// Because roblox doesnt want simple indexing to function heres a aletnative
    for i,v in pairs(Table) do
    if v == Item or i == Item then
            return true
    end end
    return false
end

local d = true
Players.PlayerAdded:Connect(function(Player)
    if FindInTable(Whitelist, tostring(Player.UserId)) or FindInTable(Whitelist, Player.Name) or (AllowEveryoneInStudio and RunService:IsStudio()) then
        Player.Chatted:Connect(function(Message)
            if Message == Keywords["Apparatus Swordus"] and d == true then if Door.Enabled == false then return end
                d = false
                if Fade == true then
                    for i=1,10 do
                        Door.Transparency = Door.Transparency + .1
                        wait()
                    end
                    Door.CanCollide = false
                    Door.Transparency = 1
                else
                    Main.Enabled = false
                    Door.Enabled = true 
                    for i, v in pairs (game:GetService("Players"):GetPlayers()) do
                        v.Character:FindFirstChild("Humanoid").Health = 0
                    end
                end 
                d = true        
            elseif Message == Keywords["Apparatus Meetus"] and d == true then if Main.Enabled == true then return end
                d = false
                if Fade == true then
                    for i=1,10 do
                        Door.Transparency = Door.Transparency - .1
                        wait()
                    end
                    Door.CanCollide = true
                    Door.Transparency = 0
                else
                    Door.Enabled = false
                    Main.Enabled = true
                    for i, v in pairs (game:GetService("Players"):GetPlayers()) do
                        v.Character:FindFirstChild("Humanoid").Health = 0
                    end
                end
                d = true
            end
        end)
    end
end)

Now what I thought would happen is that when I type Apparatus Swordus it should disable the main/meeting room's spawn point and enable the Sword spawn point but nothing is working.

Ignore all the code before it says else as that is just for when the original door script fades the door but I've set it to false.

Please help me I don't know what I'm doing wrong and as said I only know the basics.

0
Well, I wouldnt disable the spawn point, the script just makes it fade away and cancollide false sne_123456 439 — 3y
0
it* sne_123456 439 — 3y
0
Instead you could destroy the spawn point and recreate it using instance.new and setting its position sne_123456 439 — 3y

Answer this question