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

How would I turn the player Invisible using a sever sided script?

I am trying to make a function where you turn invisible if you press q and I made everything else but changing the players transparency doesn't work the script:

local Player = game.Players.LocalPlayer
local plr = script.Parent.Parent.Transparency
local dmg = true
local cooldown = false
local TransparencyI = true

game:GetService("UserInputService").InputBegan:connect(function(input, gamepor)
if (input.KeyCode == Enum.KeyCode.F or input.KeyCode == Enum.KeyCode.ButtonY) and 	TransparencyI == true and cooldown == false then -- dont touch
	plr = 1
	wait(40)
	plr = 0
	TransparencyI = false
	cooldown = true
	wait(60)
	TransparencyI = true
	cooldown = false
  end
 end)

2 answers

✓ Accepted answer

on line 2 you are simply making a shallow copy. which means, you're getting the player's current transparency at that time and that's it. the variable and the player's transparency are not linked. if you just get the actual object, though, you can still change it directly.

try this.

local plr = script.Parent.Parent
if --blah blah blah
	plr.Transparency = 1
	wait(40)
	plr.Transparency = 0
end

also unless you are using cooldown and TransparencyI elsewhere there is no point in having both when they are always opposite. you could just use one of them.

4 comments

0

I tried it and it says "Transparency is not a vaild member of Workspace.KEVINRUANO)

0

Incorrect.

0

it works, you have a different problem now. as ludzik mentioned below you cannot turn a model transparent on its own. you will have to loop through each part and set its transparency.

0

Ok that makes sense let me try it

Uhm, thats not how it really works, let me help you a bit. 1.You cant make a model transparent. 2.You cant set it to 1 and 0 and pretend its actually changing anything, dont mention .Transparency and only the player. plr.Transparency = 1 for example (ITS NOT GONNA WORK YOU CANT MAKE A MODEL TRANSPARENT BTW) the rest should work properly, i'd be nice if you gave us which line the error appears on. have a good day!

1 comment

0

I didn't get an error it just doesn't turn the player invisible

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