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
1 year 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?

--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)

0
Did you try to print on server side? enes223 327 — 1y

1 answer

Log in to vote
0
Answered by
Antelear 185
1 year ago

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.

Ad

Answer this question