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

How do I give players tools when they join a game due to the hats they're wearing?

Asked by 10 years ago

I did it cheaply where I'm going to put a can't-collided brick at every spawn, each for a hat (similar to a VIP door but for hats). I was wondering what to base the hat texture on (I went by mesh). I was also wondering how I would change the two lines labeled --this is wrong, because I'm clueless about getChildren. I was also wondering about "for i=1 and #'s, but you don't have to answer that (haha). My Code:

permission = {""} -- not needed
texture = "http://www.roblox.com/asset/?id=152725777" -- Basic Egg texture...?
function checkOkToLetIn(name) 
for i = 1,#permission do 

if (string.upper(name) == string.upper(permission[i])) then return true end 
end 
return false 
end 

local Door = script.Parent

function onTouched(hit) 
print("Part Hit") 
local human = hit.Parent:findFirstChild("Humanoid") 
if (human ~= nil ) then 
getChildren()
if human.Handle.Mesh.TextureId == texture
instance.new(toolIwant)-- this is wrong
Players.human.Backpack.-- this is wrong
elseif (checkOkToLetIn(human.Parent.Name)) then 
end 
end 
end

script.Parent.Touched:connect(onTouched)

Thank you very much for your time!

1 answer

Log in to vote
0
Answered by 10 years ago

I am not sure whether the rest of your code will work but I changed the lines that you highlighted. You will also need to place the tool into Lighting.

permission = {""} -- not needed
texture = "http://www.roblox.com/asset/?id=152725777" -- Basic Egg texture...?
function checkOkToLetIn(name) 
for i = 1,#permission do 

if (string.upper(name) == string.upper(permission[i])) then return true end 
end 
return false 
end 

local Door = script.Parent

function onTouched(hit) 
print("Part Hit") 
local human = hit.Parent:findFirstChild("Humanoid") 
if (human ~= nil ) then 
getChildren()
if human.Handle.Mesh.TextureId == texture
game.Lighting["Tool You Want Here"]:Clone().Parent = game.Players:FindFirstChild(hit.Parent.Name) or nil
elseif (checkOkToLetIn(human.Parent.Name)) then 
end 
end 
end

script.Parent.Touched:connect(onTouched)
0
line 19 is underlined in studio and doesn't seem to work... is there anything to do to fix it? thank you VERY much! I really appreciate it! dukemoepicklepoe 0 — 10y
0
What is the error? The code on line 19 looks perfect to me. Could you paste your line 19 for me? Scriptury 70 — 10y
0
My line 19 is the same (I copy and pasted) but in studio it's underlined in red and doesn't work. Is there another way? Thank you so much dukemoepicklepoe 0 — 10y
0
Can you please paste your line 19 from studio? Scriptury 70 — 10y
View all comments (2 more)
0
game.Lighting["tool"]:Clone().Parent = game.Players:FindFirstChild(hit.Parent.Name) or nil dukemoepicklepoe 0 — 10y
0
When I paste that line in studio, I get no errors. Scriptury 70 — 10y
Ad

Answer this question