Ah, it is actually good practice to not mix .Touched and a guitype's property together.
If you want to do this, I suggest getting more familar with RemoteEvents and Server to client and client to server capabilities. I would suggest learning those before attempting this, however, for the purpose of your question, I'll get down to explaining a fix.
For starters, insert a "RemoteEvent," into ReplicatedStorage, for the sake of this answer/little tutorial of mine, I may tweak the set up that I use to fit your specifications, as the set up I always use is one remote event and one remote function per game.
Name the remoteevent anything you want, I'll just keep it simple and go off, "Event," make sure your Event is in ReplicatedStorage though.
Now, let's start with the server side.
But before that, I want to state this is not the only method to set this up, you don't need a remote event, you could easily clone to the playergui and then the localscript will automatically run the code.
To the coding for the server side.
workspace.Room.Door.Stuff.Touched:connect(function(hit)
local player = game.Players:FindFirstChild(hit.Parent)
if player then
game.ReplicatedStorage.Event:FireClient(player)
end
end)
-- This will fire to, "player," which will automatically get the player that touched the part, one thing to learn is, both OnServerEvent which gets the server side of a FireServer() and FireClient() which fires from the server to the client, the first argument is ALWAYS the player, so for example. If I wanted to FireClient() to someone who joined a game just then, I'd only need to get the variable, or the default argument the PlayerAdded event gives us, same goes for the touched event. As long as the player argument is defined, it will fire to the SPECIFIC client in the first parameter, which is the player argument.
To the local side, you will want to create a localscript, anywhere is fine, but for the sake of making it simple, I'll put it in the frame that you are trying to change to visible.
local TweenService = game:GetService("TweenService")
local fadeBackground = script.Parent
game.ReplicatedStorage.Event.OnClientEvent:Connect(function()
`script.Parent.Visible = true
local tweenInfo = (
3,
Enum.EasingSty le.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local tween = TweenService:Create(fadedBackground,tweenInfo,{BackgroundTransparency = 1})
tween:Play()
end)
I didn't go to in-depth on how you can possibly make a better fade gui, however, that is up to you to decide. I have shown you the a better way of creating a fading gui, as yours just won't work regardless in all honesty, you'd have to use Filtering Enabled to the extent it won't break, and you can't set a frame to false from a server script, and it's best to keep .Touched on server(I haven't tested it out on client, but I just know it'd be best to develop it on server, never felt the obligation to see it on client) So there you have it, I hope you enjoyed my extremely long tutorial.
4 comments
It must be connected to a function.
It still will not work. I've removed an end) and also still wont. Thank you though.
Unless...Is this a local script?
use Connect, also learn to indent