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

How would I make a script that would run another script depending on who it is?

Asked by 4 years ago

How would I make a script that would run another script for that person if they own a gamepass or be a certain user?

2 answers

Log in to vote
1
Answered by
Tokyo7979 131
4 years ago
Edited 4 years ago

It's simply just an if statement and pieces of code. Here's some articles from Roblox that should help you find a solution: https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/UserOwnsGamePassAsync / https://developer.roblox.com/en-us/api-reference/property/Player/UserId

0
So would it be like: if user owns gamepass, run this script? I'm not exactly too good with scripting. It would be really nice if you could send me the solution. Agicient 0 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You would use something like this, to check if they are a certain person:

local userids = {
    1234567,
    8901234,
}
game.Players.PlayerAdded:Connect(function(player)
    for i, v in pairs(userids) do
        if player.UserId == v then
            local script = game.ReplicatedStorage:FindFirstChild("script")
            script:Clone().Parent = player.PlayerScripts
        end
    end
end)

and you could use something like this to check if they have the gamepass

local MS = game:GetService("MarketplaceService")
local GamepassId = 1234567
game.Players.PlayerAdded:Connect(function(player)
    if MS:UserOwnsGamePassAsync(player.UserId, GamepassId) then
        local script = game.ReplicatedStorage:FindFirstChild("script")
        script:Clone().Parent = player.PlayerScripts
    end
end)

EDIT: to put the sword in someone's inventory you might do something like

local script = game.ReplicatedStorage:FindFirstChild("script")
script:Clone().Parent = player.PlayerScripts
0
So now I would put in any script in that and it would run for that specific player? I mean like, lets say I wanted to put in a magic sword script such as this one (https://www.youtube.com/watch?v=FV9k81C4G0A) would I just paste in the script? Agicient 0 — 4y
0
so do you want to give this sword to whoever is whitelisted or owns the gamepass? jediplocoon 877 — 4y
0
or do you want to activate a special script for that sword jediplocoon 877 — 4y
0
That sword script is broken but, something like that. Agicient 0 — 4y
View all comments (12 more)
0
something like what? the first thing i said or the second one jediplocoon 877 — 4y
0
The first one Agicient 0 — 4y
0
Look at my edited post, that might work jediplocoon 877 — 4y
0
It isn't a tool but I appreciate it. Agicient 0 — 4y
0
So lets say I picked my script. Like one that gives the user magic or something. Would I put that script or a model with it into the replicated storage for it to run? Agicient 0 — 4y
0
If you are using a server script to duplicate it, you usually use Server Store, but if you are trying to create a duplicate locally from the player, you can put it in Lighting or Replicated Storage, basically, you can just change the code i wrote to make it check Server Storage instead if you wanted to jediplocoon 877 — 4y
0
For example, lets say I were to take this John Doe exploit script. https://pastebin.com/raw/Tz6jxS85 how would I make it that if a gamepass is purchased it would give them the script in game? Would I just paste the script into the replicated storage? The goal for this is to make a magic genre with really cool magic from exploits and whatnot. Agicient 0 — 4y
0
I really appreciate the fast response and help. Agicient 0 — 4y
0
Sorry, i had to go do some stuff, but if it was just a script, you would put the script in replicated storage before you start the game, and in the script you would tell that script to go to player.PlayerScripts jediplocoon 877 — 4y
0
I've edited my post so it should work jediplocoon 877 — 4y
0
I've tried and it wont work. To be more clear, how would I get exploit scripts in my game. Like grab knife or those really cool magic ones. Agicient 0 — 4y
0
I don't know how any of those "exploits" work, but if what you are asking is how to get them in your game just go to the toolbox and select them jediplocoon 877 — 4y

Answer this question