Help With Remote Events

ohhh, makes much more sense,
let me reiterate what you mean
so basically,

first, player activates proximity prompt
second, a gui pops up for the player client
and third, player presses the button on the gui and there’s a remote event that fires from the client to the server
then, the server waits until it receives the event and finally it plays the animation

is that correct?

1 Like

i think instead checking under the proximity prompt function, couldn’t you use something on the server side to receive the fired remote event, instead of using a while loop to check for visible property change?

server sided function

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remote_event = ReplicatedStorage:WaitForChild("RemoteEvent")

local function playAnimation()
openAnim:Play()
openAnimation.Stopped:Wait()
closeAnim:Play()
end

remote_event.OnServerEvent:Connect(playAnimation)

client sided fire event

local ReplicatedStorage = game:GetService("ReplicatedStorage")
 
local remote_event = ReplicatedStorage:WaitForChild("RemoteEvent")
 
-- Fire the remote event
remote_event:FireServer()

Yes, that’s what I want to happen.

1 Like

Great code, but there’s one problem. It is a fridge in a restaurant, so I want to replicate it many times, and I don’t want to have to go in a change the code each time, so I don’t know what to do.

1 Like

yeah i got one solution for you,
the tag editor plugin

if you need help using it, just ask me, but basically you can keep all your code in one script

1 Like

Thank you for the suggestion. I have many applications for my game and I am very excited to use it, but I’m not sure how it could help me. Could you please elaborate on your solution?

When you say replicate it multiple times, are you referring to there being multiple fridges, and you would like all of them to have this effect? Also I’d recommend keeping all UI stuff client sided, it helps in the long run. Here is a proposed solution you could, in theory use. If you’re looking to have the animation on the client side, have you thought of TweenService? It might be easier then firing a remote
to activate that fridge.

Keep in mind for this to work, use the Tag Editor plugin as shown above. Click on the plugin, press “Create new tag”, name it “Fridge”, and while you have “Fridge” selected, select all of the fridges in your game.

-- client
local CollectionService = game:GetService("CollectionService")
local Fridges = CollectionService:GetTagged("Fridge")
local fridgeGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("FridgeGUI")

local selectedFridge 


for _, fridge in pairs(Fridges) do 
	fridge.ProximityPrompt.Triggered:Connect(function(plr)
		if plr == game.Players.LocalPlayer then
		selectedFridge = fridge
			fridgeGui.FridgeGUIFrame.Visible = true
		end
	end)
end

-- at this point, i assume the gui is probably closed by pressing a button. change this to the name of the button.

fridgeGui.FridgeGUIFrame.Close.MouseButton1Click:Connect(function()
	fridgeGui.FridgeGUIFrame.Visible = false
	game.ReplicatedStorage.RemoteEvent:FireServer(selectedFridge)
end)
-- server
local function AnimateFridge(plr, Fridge)
	local animator = Fridge.AnimationController.Animator
	local openAnimation = Fridge.Animations.DoorOpen
	local closeAnimation = Fridge.Animations.DoorClose
	
	
	local openAnimTrack = animator:LoadAnimation(openAnimation)
	wait(0.5)
	local closeAnimTrack = animator:LoadAnimation(closeAnimation)
	
end


game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(AnimateFridge)
2 Likes

i think what they mean, is they want them to all be functional, but without having to use multiple scripts for each of them

2 Likes

alright, i’ll try my best to explain how to use collection service/tag editor plugin

so first, get the plugin (tag editor plugin),
next go to the plugin tab,
and then click on manage plugins,
image
and on the new tab scroll down until you find the tag editor plugin and click on the slider to turn it on


and then on the plugin tab, you should see the plugin, and click on both of the images
image
then there should be another tab that pops up
and then add new tag, make sure you name it accordingly, for your case i would name it “fridge”
image
click on your model and then press on the check box to tag it

and tag all the models you need to, and thats pretty much all the steps to using it

then add a script, if you doing server then preferably in server script service unless its on the client then either add it to starter gui or the start player/character scripts, it kinda depends what you’re going for

local CollectionService = game:GetService("CollectionService")
local Fridges = CollectionService:GetTagged("Fridge")

for _, fridge in pairs(Fridges) do 
--code here
end
1 Like

also here’s a testing place if you want to see the tag editor in the process
teleport_place.rbxl (76.9 KB)

1 Like

Do I put the client script in starter player scripts? Also, there are a lot of buttons within the gui that can close the gui, so how would I modify it to allow any button to close it?

probably in starter gui since you’re doing something with the gui

1 Like

I put those scripts in StarterPlayerScripts, because it wasn’t working in StarterGui, but now the game won’t load because it says there is an error loading core scripts: no verified patch could be loaded.

thats strang, i think its probably roblox is broken

Maybe, I’ll try tomorrow and reply back to say if its working.

i think you might wanna reinstall roblox studios, cause it worked for me

1 Like

How do I reinstall it? Sorry, I’m not very good at this kind of stuff.

its fine, but what i do, is first go to you search bar and type in “remove” and then something should pop up and then find roblox
i don’t know if you have mac or windows computer, but i think you got a windows computer

and this is to install roblox

1 Like

Thank you! One last thing, should I make a different script for each button in the gui or all in the same script?

i think probably the same script since it would make things a tad bit easier

1 Like