Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My script make me invisible in my client but my friend still see I'm not invisible?

I have made a script which make you invisible by clicking on the text button:

local player = game.Players.LocalPlayer
local char = player.Character
script.Parent.MouseButton1Click:Connect(function()
	
	char.Head.Transparency = 1
	char.Head.Face.Transparency = 1
	char.Torso.Transparency = 1
	char["Left Arm"].Transparency = 1
	char["Left Leg"].Transparency = 1
	char["Right Arm"].Transparency = 1
	char["Right Leg"].Transparency = 1
	wait(2)
	char.Head.Transparency = 0
	char.Head.Face.Transparency = 0
	char.Torso.Transparency = 0
	char["Left Arm"].Transparency = 0
	char["Left Leg"].Transparency = 0
	char["Right Arm"].Transparency = 0
	char["Right Leg"].Transparency = 0
end)

The script is in the text button when I click, it make me invisible, but my friend said that i have not invisible yet

2 answers

The client cannot directly change part properties as this would lead to exploiting. You would have to fire a remote event to the server where it would change the transparency of the parts.

Remote Events Tutorial

Also you should consider looking into for loops instead of typing each body part individually.

Something like this should get you going in the right direction, though I haven't tested the code.

--Server

local event = game.ReplicatedStorage.EVENTNAME

event.OnServerEvent:Connect(function(player)
	local character = player.Character or workspace:FindFirstChild(player.Name)
	for k, v in pairs(character:GetChildren()) do
		if v:IsA('BasePart') then
			v.Transparency = 1
			local decal = v:FindFirstChild('Decal')
			if decal then
				decal.Transparency = 1
			end
		end
	end
end)

Client:

local event = game.ReplicatedStorage.EVENTNAME

script.Parent.MouseButton1Down:Connect(function()
	event:FireServer(game.Players.LocalPlayer)
end)

3 comments

0

Is this any different than what I just said?

0

he included code, thats all

0

:FireServer() has no required arguments. OnServerEvent automatically returns the player that fired the remote as a parameter. Therefore, your argument in the local script is not being used

This discussion is preserved as it was. New answers, comments, and votes are closed.