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

Why won't this simple script work?

Asked by 9 years ago

What is wrong with the following that even when someone else that is not me sit's on the seat they still get the gui?

gui = game.Lighting.Control 

function getGUI(u)
print("hit")
local h = u.Parent:FindFirstChild("Humanoid")
if h ~= nil then
print("human")
local user = game.Players:GetPlayerFromCharacter(u.Parent)
local gtest = user.PlayerGui:FindFirstChild("ScreenGui")
print(u.ClassName,u.Name) 
if user.Name == "DavidWhitmore" then
if gtest == nil then
local g = gui:Clone()
g.Parent = user.PlayerGui
else return end
print("Done")
end
end
end

script.Parent.Touched:connect(getGUI)
0
try tostring(user.Name). LostPast 253 — 9y
0
Remove line 15, it serves no purpose. Also, don't put the GUI in lighting, put it in ReplicatedStorage. alphawolvess 1784 — 9y
0
@Sporkzy For which line sorry? @alpha that won't fix this though will it? DavidWhitmore 0 — 9y
0
line 11 maybe. I really hate comparing names lel LostPast 253 — 9y
View all comments (4 more)
0
Name is already read as a String. Why would you use tostring on the Players name if it already is a string? Also, Alpha is right, line 15 serves no purpose at all. And don't store things in Lighting; Either use SeverStorage or ReplicatedStorage DigitalVeer 1473 — 9y
0
I'll try to make you a script once I can access Studio. yumtaste 476 — 9y
0
I tested this and it works fine.... NotsoPenguin 705 — 9y
0
I tested it and it does not work, If I put the username to someone random and I try and sit on it...It still gives me the Gui DavidWhitmore 0 — 9y

Answer this question