Now I’m making a script that states if a player’s race is a Soul, then their Torso’s transparency turns 0.5 transparency. The script doesn’t seem to work and I need help. Thanks
local player = game.Players.LocalPlayer
if player.PlayerValues.Race == "Soul" then
Parent:FindFirstChild("Humanoid"
UpperTorso.Transparency = 0.5
end
Yes.
If you are trying to use a server for client, it won’t work exactly how you want it to since it’s the sever.
Client is the actual player.
If you do it reverse which is server for client and client for server, the client would fail because it’s not designed to be for the server.
If that one was script, you can’t declare player as “game.Players.LocalPlayer” as I was saying.
so what you have to do is:
game.Players.PlayerAdded:Connect(function(Player) -- Fire this script when player added
repeat wait() until Player:FindFirstChild("PlayerValues") -- Wait and repeat until PlayerValues found.
local Datas = Player:FindFirstChild("PlayerValues") -- Double check
if Datas then
if Datas:FindFirstChild("Race") then -- Check "Race"
Data.Race.Changed:Connect(function(NewValue) -- Fire when Data is changed
if NewValue == "Soul" and Player.Character then -- If NewValue was "Soul" and Character found
Player.Character.UpperTorso.Transparency = 0.5 -- Make your action
elseif Player.Character then -- If others, changing back? at least your must check that player has character
Player.Character.UpperTorso.Transparency = 0
end
end
end
end
end)
-- Error fixed by MrMauio
local player = game.Players.LocalPlayer
if player.PlayerValues.Race.Value == 'Soul' then
local char = player.Character
char:FindFirstChild("Humanoid")
char.UpperTorso.Transparency = 0.5
end
game.Players.PlayerAdded:Connect(function(Player) -- Fire this script when player added
repeat wait() until Player:FindFirstChild("PlayerValues") -- Wait and repeat until PlayerValues found.
local Datas = Player:FindFirstChild("PlayerValues") -- Double check
if Datas then
if Datas:FindFirstChild("Race") then -- Check "Race"
Data.Race.Changed:Connect(function(NewValue) -- Fire when Data is changed
if NewValue == "Soul" and Player.Character then -- If NewValue was "Soul" and Character found
Player.Character.UpperTorso.Transparency = 0.5 -- Make your action
elseif Player.Character then -- If others, changing back? at least your must check that player has character
Player.Character.UpperTorso.Transparency = 0
end)
end
end
end
end)
It looks like you are very new to this so let me explain.
Lua cannot find any variable named ‘Parent’ or any variable named ‘UpperTorso’.
You need to use your ‘player’ variable that references the local Player object so that you can find the player’s upper torso like this:
game.Players.PlayerAdded:Connect(function(Player) -- Fire this script when player added
repeat wait() until Player:FindFirstChild("PlayerValues") -- Wait and repeat until PlayerValues found.
local Datas = Player:FindFirstChild("PlayerValues") -- Double check
if Datas then
if Datas:FindFirstChild("Race") then -- Check "Race"
Data.Race.Changed:Connect(function(NewValue) -- Fire when Data is changed
if NewValue == "Soul" and Player.Character then -- If NewValue was "Soul" and Character found
Player.Character.UpperTorso.Transparency = 0.5 -- Make your action
elseif Player.Character then -- If others, changing back? at least your must check that player has character
Player.Character.UpperTorso.Transparency = 0
end
end)
end
end
end)
One thing I saw was that the “Data” variable on line 6 to not be the same as the “Datas” variable previously stated in the beginning so I changed it to “Datas” and still no result. (I dont know if its supposed to be like that I just tried)
And there was no error in the output nothing was said