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

How do I make vip sever host commands?

Asked by 4 years ago

Right know I’m making a fighting type of game and I’m trying to make it so if you buy a vip sever you get host commands what only the vip sever host can access and I don’t know what I’m suppose to script because I’ve never done that before so can someone help me with that?

2 answers

Log in to vote
0
Answered by
chasedig1 115
4 years ago

https://devforum.roblox.com/t/detecting-who-owns-the-vip-server-and-giving-them-a-gui/313775

The UserId of the owner of the VIP server can be found by the code below:

game.VIPServerOwnerId

Now, give only the person who owns the VIP server a GUI. When they try to activate a certain feature of the menu, check if they own the VIP server. If so, then you can activate that feature on the server.

Get a player's UserId using:

game.Players.PlayerNameHere.UserId
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

First you have to check the type of server it is. I'm pretty sure it's like this


if game.VIPServerId ~= "" or game.VIPServerOwnerId ~= 0 then end

https://devforum.roblox.com/t/how-to-check-if-a-server-is-a-vip-server/90409

Now that you can find out it it is a vip server or not, it's time to work on the code if it is a vip server.

Also put this code in a server script in ServerScriptService and name it VipServerHandler.

local CommandPrefix = '/' -- Change this to your liking

if game.VIPServerId ~= "" or game.VIPServerOwnerId ~= 0 then
    local buyerId = game.VIPServerOwnerId
    local buyer = game.Players:GetPlayerByUserId(buyerId)

    -- Now the vip commands
    -- I'm not sure if you want support for the command to be case-unsensitive, just let me know if you want

    buyer.Chatted:Connect(function(message)
        if message:sub(1,6) == CommandPrefix .. "kick " then     
                    game.Players[message:sub(7)]:Kick()
        elseif message:sub(0,0) == CommandPrefix .. "" then
            -- Add more commands yourself
        end
    end)
end

The only important things here is string manipulation and the player.Chatted event.

Note: :sub is spelt with a lower-case s

I hope this helps :)

Answer this question