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

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

Asked by
R0jym 47
2 years ago

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?

01--LOCALSCRIPT
02 
03 
04local RS = game:GetService("ReplicatedStorage")
05local DisasterEvent = RS.DisasterEvent
06local TimerEvent = RS.TimerRemote
07 
08local Timer = script.Parent
09 
10local function trigger()
11    DisasterEvent:FireServer()
12end
13 
14if Timer.Text == "0" then
15    trigger()
16    DisasterEvent:FireServer()
17end

Here is the Server Script:

01--SERVERSCRIPT
02 
03local RS = game:GetService('ReplicatedStorage')
04local DisasterEvent = RS.DisasterEvent
05local part = game.Workspace.Grass
06 
07DisasterEvent.OnServerEvent:Connect(function(pleaseworkalreadybroivehadenough)
08    part.Transparency = 0
09    DisasterEvent:FireClient()
10end)
0
Did you try to print on server side? enes223 327 — 2y

1 answer

Log in to vote
0
Answered by
Antelear 185
2 years ago

What you could do is;

1--LOCALSCRIPT
2 
3--Pretend you had the rest of your code up top and you made a variable pointing to your part instance named "DisasterPart".
4 
5if Timer.Text == "0" then
6    DisasterEvent:FireServer(DisasterPart)
7end

Then;

1--SERVERSCRIPT
2 
3DisasterEvent.OnServerEvent:Connect(function(Player, Part)
4    Part.Transparency = 0
5end) -- "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.

Ad

Answer this question