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?
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:
1 | 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:
1 | game.Players.PlayerNameHere.UserId |
First you have to check the type of server it is. I'm pretty sure it's like this
1 | if game.VIPServerId ~ = "" or game.VIPServerOwnerId ~ = 0 then |
2 |
3 | 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.
01 | local CommandPrefix = '/' -- Change this to your liking |
02 |
03 | if game.VIPServerId ~ = "" or game.VIPServerOwnerId ~ = 0 then |
04 | local buyerId = game.VIPServerOwnerId |
05 | local buyer = game.Players:GetPlayerByUserId(buyerId) |
06 |
07 | -- Now the vip commands |
08 | -- I'm not sure if you want support for the command to be case-unsensitive, just let me know if you want |
09 |
10 | buyer.Chatted:Connect( function (message) |
11 | if message:sub( 1 , 6 ) = = CommandPrefix .. "kick " then |
12 | game.Players [ message:sub( 7 ) ] :Kick() |
13 | elseif message:sub( 0 , 0 ) = = CommandPrefix .. "" then |
14 | -- Add more commands yourself |
15 | end |
16 | end ) |
17 | 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 :)