Hello, so basically what im trying to do is make a script where you press a button then it makes a person invisible or visible and based on their stats they are invisible or visible. so if the client is invisible then if they have less stats then another client they are semi invisible to the other client but if the client has more stats then the other client then they are completely invisible to the other client. i have a server script and 2 local scripts that do this whole function process. 1 local scripts in the character which listen for the key pressed and fire a function to all clients.
local script #1:
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local char = player.Character
local db = true
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent, event)
if gameProcessedEvent then return end
if input.KeyCode == Enum.KeyCode.V and db then
db = false
print("Working")
game.ReplicatedStorage.Events.INVISIBLITYYY:FireServer()
if char.Head.face.Transparency == 1 then
print("invisible")
for _, Part in pairs(char:GetDescendants())do
if Part:IsA("BasePart") or Part:IsA("MeshPart") then
Part.Transparency = 0
char.Head.face.Transparency = 0
char.HumanoidRootPart.Transparency = 1
local vision = "visible"
script.Parent.Vision:FireServer(vision)
end
end
elseif char.Head.face.Transparency == 0 then
print("visible")
for _, Part in pairs(char:GetDescendants())do
if Part:IsA("BasePart") or Part:IsA("MeshPart") then
Part.Transparency = 0.7
char.Head.face.Transparency = 0.7
local vision = "invisible"
script.Parent.Vision:FireServer(vision)
end
end
end
wait(.5)
db = true
end
end)
this script listens for the key and makes the character invisible locally and fires a event with a variable called "vision" witch can equal either "invisible" or "visible".
next is script #2:
local character = script.Parent
local Players = game:GetService("Players")
local player = Players:GetPlayerFromCharacter(character)
script.Parent.Vision.OnServerEvent:Connect(function(plr, vision)
game.ReplicatedStorage.Events.INVISIBLITYYY:FireAllClients(plr, vision)
end)
this simply gets the event and fires it then to all other clients with the plr and the vision variable.
local script #3:
game.ReplicatedStorage.Events.INVISIBLITYYY.OnClientEvent:Connect(function(plr, vision)
local char = plr.Character
print(char.Name)
local stats = plr.stats.Phychic.Value
local MyPLR = game.Players.LocalPlayer
local MyStats = plr.stats.Phychic.Value
print(vision)
if vision == "visible" then
for _, Part in pairs(char:GetDescendants())do
if Part:IsA("BasePart") or Part:IsA("MeshPart") then
Part.Transparency = 0
char.Head.face.Transparency = 0
char.HumanoidRootPart.Transparency = 1
end
end
elseif vision == "invisible" then
if MyStats > stats then
for _, Part in pairs(char:GetDescendants())do
if Part:IsA("BasePart") or Part:IsA("MeshPart") then
Part.Transparency = 0.6
char.Head.face.Transparency = 0.6
char.HumanoidRootPart.Transparency = 1
end
end
elseif MyStats < stats then
for _, Part in pairs(char:GetDescendants())do
if Part:IsA("BasePart") or Part:IsA("MeshPart") then
Part.Transparency = 1
char.Head.face.Transparency = 1
end
end
end
end
end)
this local script is inside of playergui and it listens for the fireallclient and then it gets its player and the player that fired the function. it gets the clients stats and the player who pressed the keys stats it then compares and makes them either invisible or visible by checking stats and the variable named "vision".
hopefully someone can find the problem i am making or maybe my script has no problems and it isnt placed in the right area. well thank you in advanced!

3 comments
allready tried but it diddnt work.
Well other than that I see no other problems. May I suggest you space out your code and go through every line of code you have to try and spot the mistake.
OK