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

changing the output depending on r6 or r15?

i attempted to edit some giver script i found on youtube:

local item = game:GetService("ReplicatedStorage"):WaitForChild("Bloxy Cola")
local db = true

script.Parent.Touched:connect(function(part)
 if part.Parent:FindFirstChild("Humanoid") ~= nil then
  local player = game.Players:GetPlayerFromCharacter(part.Parent)
  if player ~= nil then
   if player.Backpack ~= nil then
    if db == true then
     db = false
if part.Parent:FindFirstChild("Torso") then -- if the r6 torso exists give it to em
     item:Clone().Parent = player.Backpack
else
	part.Parent.UpperTorso.CFrame = CFrame.new(1.657, -0.052, 91.883)
     wait(60) -- if it doesnt then teleport them to spawn
     db = true
    end
   end
  end
 end
end)




I will replace the teleport with a new item to be given, but the code doesnt work entirely. what am i doing wrong here?

1 comment

0

What exactly is supposed to happen? What is the goal of this script? It's hard to fix your problem if you do not describe what is meant to occur.

1 answer

✓ Accepted answer

Try this version

local item = game:GetService("ReplicatedStorage"):WaitForChild('Bloxy Cola')
local db = true

local function ScanRigType(player)
    if player and player.Character and player.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then -- check if rig type is r6
        return true -- return true if rig type is r6
    end
    return false -- return false if rig type is r15
end

script.Parent.Touched:Connect(function(part)
    local player = game:GetService('Players'):GetPlayerFromCharacter(part.Parent)
    if player ~= nil and player.Backpack ~= nil and db then
        db = false
        if ScanRigType(player) then -- if rig type is r6 exists give it to em
            local item1 = item:Clone()
            item1.Parent = player.Backpack
        else
            player.Character:MoveTo(Vector3.new(1.657, -0.052, 91.883))
            wait(60) -- if it doesnt then teleport them to spawn
        end
        db = true
    end
end)

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