Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago

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

Log in to vote
0
Answered by
Speedmask 661 Moderation Voter
3 years ago

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.

0
I tried it and it says "Transparency is not a vaild member of Workspace.KEVINRUANO) KEVINRUANO 12 — 3y
0
Incorrect. UAStudio 39 — 3y
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. Speedmask 661 — 3y
0
Ok that makes sense let me try it KEVINRUANO 12 — 3y
Ad
Log in to vote
1
Answered by
Ludzik78 136
3 years ago

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!

0
I didn't get an error it just doesn't turn the player invisible KEVINRUANO 12 — 3y

Answer this question