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

Is there a way to give a tool to a certain player or rank only?

Asked by 5 years ago

So basically it's an animation tool so it's not a Roblox gear, so would there be a way for only certain people or certain people from a rank to have it available or visible to them?

script.Parent.Equipped:connect(function(m)
    m.Button1Down:connect(function()
         hum = game.Players.LocalPlayer.Character.Humanoid
         anim_feet = hum:LoadAnimation(script.Parent.Animation)
        current = anim_feet
        current:Play()
    end)
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Hi Cantbeatmerbro,

Yes, you can give it to them using the .CharacterAdded event. Also, you can make it visible to only them by placing it in the CurrentCamera. So, here, I'll just show you an example of where i make it visible only to certain players. For this, you'll need 2 scripts. One Local Script and One Server Script. The ServerScript is going to be in ServerScriptService and the LocalScript is in StarterPack.

Server Script

local players = game:GetService("Players");
local rs = game:GetService("ReplicatedStorage");
local allowed_to_have_tools = {
    ["KingLoneCat"] = true;
    ["Cantbeatmerbro"] = true;
    ["Player1"] = true;
}
local parent_ev = rs:WaitForChild("Parent To Current Camera");

players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        if allowed_to_have_tools[char.Name] then
            parent_ev:FireClient(player);
        end
    end)
end)

Local Script

local cam = workspace.CurrentCamera;
local rs = game:GetService("ReplicatedStorage");
local parent_ev = rs:WaitForChild("Parent To Current Camera");

parent_ev.OnClientEvent:Connect(function()
    local tool = script:WaitForChild("Tool To Make Visible");

    tool.Parent = cam;
end)

I used a RemoteEvent to communicate between the ServerScript and a LocalScript. You might be wondering why I used a LocalScript, and that's simply because you need a LocalScript to access CurrentCamera. CurrentCamera is where all local things go, so if you want there to be parts that only one Player can see, then you'd place it in the CurrentCamera.

Well, I hope I helped and have a wonderful day/night.

Thanks,

Best regards,

~~ KingLoneCat

Ad

Answer this question