Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

1 comment

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.

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

16 comments

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?

0

so do you want to give this sword to whoever is whitelisted or owns the gamepass?

0

or do you want to activate a special script for that sword

0

That sword script is broken but, something like that.

0

something like what? the first thing i said or the second one

0

The first one

0

Look at my edited post, that might work

0

It isn't a tool but I appreciate it.

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?

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

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.

0

I really appreciate the fast response and help.

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

0

I've edited my post so it should work

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.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.