Hi! So I have made a feature in my game that basically is an outfit changer, that when you walk onto a part it changes your character’s shirt and pants to a different one. The script works perfectly fine but I don’t know how allow this to work for only me for example.
This is my current script:
local player = game.Players.LocalPlayer
local ChangerPart = script.Parent
local OutfitChanger = ChangerPart.Parent
local ShirtTemplate = OutfitChanger.Shirt.ShirtTemplate
local PantsTemplate = OutfitChanger.Pants.PantsTemplate
ChangerPart.Touched:Connect(function(TouchPart)
if TouchPart and TouchPart.Parent and TouchPart.Parent:FindFirstChild("Humanoid") then
print("A player is standing on the changer part!")
local Character = TouchPart.Parent
Character.Shirt.ShirtTemplate = ShirtTemplate
Character.Pants.PantsTemplate = PantsTemplate
end
end)
So just to make it clear, my aim is to make this script work only for a specific player (me) so an edited version of my script that would only work for a specific player (me). I’ve tried many other scripts and trying it myself but never seems to work!
Any help will be much appreciated! Sorry I am very new to Roblox Developing.
Hello, there.
Just to add to DreamWakeStudios reply, here’s what that would look like, if you’re confused:
local player = game.Players.LocalPlayer
local ChangerPart = script.Parent
local OutfitChanger = ChangerPart.Parent
local ShirtTemplate = OutfitChanger.Shirt.ShirtTemplate
local PantsTemplate = OutfitChanger.Pants.PantsTemplate
local playersAllowed = {0000,0000} -- You put their UserId's here, seperated by a comma, for each player, who should be allowed.
ChangerPart.Touched:Connect(function(TouchPart)
if TouchPart and TouchPart.Parent and TouchPart.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(TouchPart.Parent)
if not player then return end
if table.find(playersAllowed, player.UserId) then
print("A player is standing on the changer part!")
local Character = TouchPart.Parent
Character.Shirt.ShirtTemplate = ShirtTemplate
Character.Pants.PantsTemplate = PantsTemplate
end
end
end)
Sorry about the late reply, WiFi went down lol. But anyways thanks so much for the help! It works! Also thanks very much for adding to @DreamWakeStudios reply and helping with the script, was a bit confused at first but now get it! Much appreciated mate, thanks a lot for the help!