2016-08-13 222 views
0
pnts = script.Pants 
shirt = script.Shirt 

function onClicked(playerWhoClicked) 

end 
function GiveClothes(character) 
if not character:findFirstChild("Shirt") then 
shirt:Clone().Parent = character 
else character:findFirstChild("Shirt"):Destroy() 
shirt:Clone().Parent = character 
end 

if not character:findFirstChild("Pants") then 
pnts:Clone().Parent = character 
else character:findFirstChild("Pants"):Destroy() 
pnts:Clone().Parent = character 
end 
end 

game.Players.PlayerAdded:connect(function(p) 
p.CharacterAdded:connect(function(char) 
wait(1.12) 
local plr = game.Players:findFirstChild(char.Name) 
print(char.Name) 

local groupid = 0 -- Id of your group 

local plr = game.Players:GetPlayerFromCharacter(part.Parent) 

if plr then 

if plr:IsInGroup(groupid) then 

if plr:GetRoleInGroup(groupId) >= 50 
then GiveClothes(char) 
end 
end 
end 

script.Parent.ClickDetector.MouseClick:connect(onClicked) 

如果你点击按钮(脚本在按钮下面,是的,还有一个ClickDetector),这个脚本应该给你一些衣服,但它只会给你衣服,如果你在一个集团中有一定的排名。Roblox OnClick clothers的提供者脚本

但目前它不工作。如何解决这个问题?

+0

一定要包含大量的信息。简单地说,“它不起作用”不会让人想要帮助你,因为事实是任何事情都行不通。确保在输出中查找任何错误,并且如果有任何错误将其添加到您的问题! – Klink45

回答

0

避免怪异的名字,像pnts,你可能不添加字母a

The ClickDetector already give you the player

模具中,是所有杂乱

试试这个:

local Pants = script.Pants 
local Shirt = script.Shirt 

local GroupID = 42 -- Group id here 

script.Parent.ClickDetector.MouseClick:connect(function(Player) 
    if not Player:IsInGroup(GroupID) then return end 
    if Player:GetRoleInGroup(GroupID) < 50 then return end 
    local Character = Player.Character 
    if Character == nil then return end 

    -- Get new shirt 
    local CharacterShirt = Character:findFirstChild("Shirt") 
    if CharacterShirt then CharacterShirt:Destroy() end 
    Shirt:Clone().Parent = Character 

    -- Get new pants 
    local CharacterPants = Character:findFirstChild("Pants") 
    if CharacterPants then CharacterPants:Destroy() end 
    Pants:Clone().Parent = Character 
end) 

而且当您寻求帮助时,请务必发帖errors