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

Why doesn't my give handcuffs if you are on the cops team script work?

I am trying to make it so that if you are on a team called coppo's you get handcuffs i stored in replicated storage but it doesn't work heres the code

local Player = game:GetService("Players")
local Team = game.GetService("Team")
local handcuffs = game.ReplicatedStorage.Handcuffs
if Player.Team.Name == "Coppo's" then
	handcuffs.Parent = game.StarterPack
end

also how do you put a picture in your question

3 comments

0

to put a picture you can upload it to some other site and then give link

0

oh thx

0

Game:GetService("Players") returns a table of all the players in the game, I recommend switching this to a local script, and set the handcuffs parent to "game.Players.LocalPlayer.Backpack". Also, I recommend setting something up so you can detect when a player has changed team, as the code you gave would only check it once, when they are probably not on that team yet.

1 answer

✓ Accepted answer

you need to give them the handcuffs when their character loads in so

game:GetService("Players").LocalPlayer.CharacterAdded:Connect(function(character)--we save this variable in case you need it for something else
game:GetService("ReplicatedStorage").Event:FireServer()
end

and for the server script

local serverstorage = game:GetService("ServerStorage")
game:GetService("ReplicatedStorage").Event.OnServerEvent:Connect(function(player)
	if player.Team.Name == "Coppo's" then
		serverstorage.Handcuffs:Clone().Parent = player:WaitForChild("Backpack")--dont ever save things like that in starterpack, if you do so then that thing you save to starterpack will be available to everyone
	end
end)

also dont save things like that in replicated storage, that place it ment for events, instead save in serverstorage

4 comments

0

thanks it worked!

0

np, hope you learned something

0

You can store things in ReplicatedStorage and ServerStorage. They are both meant to store items for later use in the game.

0

you shouldnt store in replicated storage unless you want that to be open for exploits, thats what server storage helps with, cant be accessed using local scripts

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