I want to achieve something that if you press T
that it will toggle the invisible status on the server and regarding to the status it will set the parts transparency, the issues with this is though that it only sets the transparency for the HumanoidRootPart
.
These are the scripts i already tried using which are also the current state of the invisible script right now
Server script:
local SkillEvent = game.ReplicatedStorage.Events:WaitForChild("SkillEvent")
local InvisibleStatus = false
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
SkillEvent.OnServerEvent:Connect(function(_,KEY)
if KEY == "Invisible[T]" then
if not InvisibleStatus then
for i,Child in pairs(Character:GetChildren()) do
if Child:IsA("MeshPart") then
Child.Transparency = 1
elseif Child:IsA("Part") then
Child.Transparency = 1
end
if Child:IsA("Accessory") then
for i,Child in pairs(Child:GetChildren()) do
if Child:IsA("Part") then
Child.Transparency = 1
end
end
end
Character.Head.face.Transparency = 1
end
InvisibleStatus = true
end
if InvisibleStatus then
for i,Child in pairs(Character:GetChildren()) do
if Child:IsA("MeshPart") then
Child.Transparency = 0
elseif Child:IsA("Part") then
Child.Transparency = 0
end
if Child:IsA("Accessory") then
for i,Child in pairs(Child:GetChildren()) do
if Child:IsA("Part") then
Child.Transparency = 0
end
end
end
Character.Head.face.Transparency = 0
end
InvisibleStatus = false
end
end
end)
end)
end)
Localscript:
local SkillEvent = game.ReplicatedStorage.Events:WaitForChild("SkillEvent")
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(InputKey)
if InputKey.KeyCode == Enum.KeyCode.T then
SkillEvent:FireServer("Invisible[T]")
end
end)
So, frankly, I’m not really looking at your script, I would edit my message later if I find the problem, but understand that letting the client call an event which tells the server to make the user invisible can be activated by a exploiter , in your case it is not very serious because in any player one just has to click on a key of the keyboard
If your goal is to make a game with skills that unlock with levels, the exploiters can currently use the skills without the right level
Otherwise always looking quickly, try to use the value “i” in your For
I used Google translator is is don’t make sense
Well i was thinking of fixing that later, now i just want to concentrate on doing the skills
1 Like
Try using someting like that
local model = workspace:FindFirstChild("PLAYERNAME")
local descendants = model:GetDescendants() -- you can use :GetChildren() if there are not BaseParts parented to another BasePart
for i = 1,10 do
wait(.01)
for i=1,#descendants do
local descendant = descendants[i]
if descendant:IsA("BasePart") then
descendant.Transparency = descendant.Transparency + 0.1
end
end
end

A main issue you have here, is that you are using PlayerAdded and CharacterAdded to get the player character, when you should be using the parameter that gets sent from the client. You want to get the player/character like this:
SkillEvent.OnServerEvent:Connect(function(player,KEY)
character = player.character
end)
Your code doesn’t work, because the Skill Event could could be coming from any client. Just slapping it inside of a .PlayerAdded event does not mean it will only receive transmission from that player’s client.
This might not be what is causing your transparency problem, but it needs to be fixed, unless you want this entire script to break when you try to run it with multiple players.
2 Likes
Well it worked before i added the boolean value to it (When it only could’ve made the player invisible but not visible)
Save a boolean value which will be checked by the event to know if the player has already activated his skill or check if the transparency of his body is at 1 (invisible) or not
Then you do the opposite action of invisible if the event detects it invisible
The problem is it won’t work when you add more players into this game. The code only works now, because one player exists in studio.
In response to your issue with transparency, the actually transparency code looks fine. Are you getting any errors in the output? Use print()'s to figure out what point does it stops at.