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

How to fix part not changing transparency to 0 even conditions are successfully met?

Hello there, I have both LocalScripts and a server script here where if the TextLabel changes to 0, the LocalScript fires a RemoteEvent called DisasterEvent of which will then result to a part changing it's transparency to 0 for every players, not just the player, however it does not seem to work after what I did, how do I fix this?

--LOCALSCRIPT


local RS = game:GetService("ReplicatedStorage")
local DisasterEvent = RS.DisasterEvent
local TimerEvent = RS.TimerRemote

local Timer = script.Parent

local function trigger()
	DisasterEvent:FireServer()
end

if Timer.Text == "0" then
	trigger()
	DisasterEvent:FireServer()
end

Here is the Server Script:

--SERVERSCRIPT

local RS = game:GetService('ReplicatedStorage')
local DisasterEvent = RS.DisasterEvent
local part = game.Workspace.Grass

DisasterEvent.OnServerEvent:Connect(function(pleaseworkalreadybroivehadenough)
	part.Transparency = 0
	DisasterEvent:FireClient()
end)

1 comment

0

Did you try to print on server side?

1 answer

What you could do is;

--LOCALSCRIPT

--Pretend you had the rest of your code up top and you made a variable pointing to your part instance named "DisasterPart".

if Timer.Text == "0" then
	DisasterEvent:FireServer(DisasterPart)
end

Then;

--SERVERSCRIPT

DisasterEvent.OnServerEvent:Connect(function(Player, Part)
	Part.Transparency = 0
end) -- "Player" (the one who fired) is the first and default argument.

And here's a tip:

  • Instead of doing game.Workspace, you can do workspace instead, and it'll work! :3

If this helped, please mark this as the answer which helped.

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