I am adding an easter egg to my game so that when you say “let me be clear” it will make you clear, but the problem is whenever you chat it makes you transparent, and I don’t know why
local ts = game:GetService("TweenService")
game.ReplicatedStorage.SpecialChatEvent.OnServerEvent:Connect(function(plr,text)
if text == "Let me be clear" or "let me be clear" then
local char = plr.Character
local things = char:GetDescendants()
for i = 1, #things do
if things[i]:IsA("BasePart") or things[i]:IsA("Decal") and things[i].Name ~= "HumanoidRootPart" then
local Info = TweenInfo.new(3)
local Tween = game:GetService("TweenService"):Create(things[i],Info,{Transparency=0.85})
Tween:Play()
end
end
end
end)
@Doomcolp has stated the correct solution so I suggest following their post. In addition to this I also suggest changing it to player.Chatted instead of receiving it from the client because:
It is the same thing since you are looking for every message coming from textchatservice
Client side can be exploited by exploiters and false information can be sent to the server, for example the “let me be clear” prompt can be sent by exploiters even though they haven’t said it
player.Chatted returns an unfiltered version of the message, this allows you to check for the message without worrying about filters.
--Code A
if text == "Let me be clear" or text == "let me be clear" then
or write it if string.lower(text) == "let me be clear" then@Doomcolp said same thing.
even text isn’t “Let me be clear”, it passes because “Let me be clear” is literally “Let me be clear”.
It’s like SQL injection. hackers uses it to access server even password or username is wrong
example:
if password or 1 == 1
also you can do it like this
-- Code B
local Texts = {
"Let me be clear",
"let me be clear"
}
if table.find(Texts,text) then
but it will be long so Code A is better. use Code B for long If statement.
and
local things = char:GetDescendants()
for i = 1, #things do
if things[i]:IsA("BasePart") or things[i]:IsA("Decal") and things[i].Name ~= "HumanoidRootPart" then
local Info = TweenInfo.new(3)
local Tween = game:GetService("TweenService"):Create(things[i],Info,{Transparency=0.85})
Tween:Play()
end
end
You can make it like this:
for i,thing in ipairs(char:GetDescendants()) do
if thing:IsA("BasePart") or thing:IsA("Decal") and thing.Name ~= "HumanoidRootPart" then
local Info = TweenInfo.new(3)
local Tween = game:GetService("TweenService"):Create(thing,Info,{Transparency=0.85})
Tween:Play()
end
end
But a print statement in the in pairs loop outside of the if statement’s scope and also one in the if statement’s scope
Just to see if the code is running. & if it is, then I’ll try to do some testing on my own
Also both wiizzzzzzzaaaaard and ALonelyGalaxy are right too (dont feel like typing a lot today though but yeah)
just figured it out lol after the solution was marked
you can’t index a child from an Instance with a number in square braces like that. You’d need to use Parent:GetChildren() and use square brace notation there.
But using a in pairs loop like wiizzzzzzzaaaaard did is the better solution