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

Why will not FireAllClients() work?

Asked by 5 years ago
Edited 5 years ago

I am trying to tween a Frame's position for everyone.

Here is the local script in the client

`local repStore = game:GetService("ReplicatedStorage") local remote = repStore:WaitForChild("cool") f = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame

remote.OnClientEvent:connect(function() f:TweenPosition(UDim2.new(1, 0, 0, 0), 'Out', 'Linear', 1)

end)`

Here is the script in Serverscriptservice

`local repStore = game:GetService("ReplicatedStorage") local remote = repStore:WaitForChild("cool")

button = game:GetService("StarterGui").ScreenGui.Frame.TextButton

button.MouseButton1Click:connect(function() remote:FireAllClients() end)

`

My remoteevent is in ReplicatedStorage named 'cool'

All that it's suppose to do is, when i click a button the frame moves to the otherside of the screen, and EVERYONE can see it move

0
put it in code blocks User#23365 30 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

StarterGui is what clones to the PlayerGui when a player joins, so you cant edit that. Also you cant enter the playergui with a server script. So, you have to insert a localscript, do

also insert a second remoteevent to the replicatedstorage, maybe called "cool2"

local repStore = game:GetService("ReplicatedStorage") 
local remote = repStore:WaitForChild("cool")

button = script.Parent

button.MouseButton1Click:connect(function()
remote:FireServer() 
end)

remote script:

game.ReplicatedStorage.cool.OnServerEvent:Connect(function(plr)
game.ReplicatedStorage.cool2:FireAllClients(plr)
end)

cool2 remote script:

game.ReplicatedStorage.cool2.OnClientEvent:Connect(function()
local plr = game.Players.LocalPlayer
-- whatever script
end)

I know the answer i gave you is pretty dumb, but i hope it helped.

0
Should the cool2 script be a local script or a regular script? - u put 'OnClientEvent' So im confused because it will only run that in a local script NinjaXDpro 22 — 5y
0
It worked, Thanks very much! I've been looking all day NinjaXDpro 22 — 5y
0
The cool2 script has to be a localscript on th eplayergui. You can accept my answer if you want, but you dont have to. jdm4llfem8 94 — 5y
Ad

Answer this question