Hi, I have a local script inside the Starter Pack that has a server script with a remote function inside it.
The function works perfectly but the problem is that nobody else can see the actual script except the client.
I've tried OnServerInvoke but that comes up with 'OnServerInvoke can only be implemented by server'
I know I could just use a server side script and make it fire the function in the Backpack but I want the function to work like a local script in the backpack and fire every time the player respawns.
Any sort of help is always appreciated.
On serverInvoke requires a non local script. A local script Invokes the server and the server through a normal script listens for it.
so you would make the event and have event.ServerInvoke:connect(function) on the server, and have a local script that finds the event and Invokes it with a variable.
-- Script local Players = game:GetService("Players") local welcomePlayerEvent = Instance.new("RemoteEvent") welcomePlayerEvent.Parent = game.ReplicatedStorage welcomePlayerEvent.Name = "WelcomePlayerEvent" local function onPlayerAdded(player) welcomePlayerEvent:FireClient(player) end Players.PlayerAdded:Connect(onPlayerAdded)
--LocalScript local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local player = Players.LocalPlayer local welcomePlayerEvent = ReplicatedStorage:WaitForChild("WelcomePlayerEvent") local playerGui = player:WaitForChild("PlayerGui") local welcomeScreen = Instance.new("ScreenGui") welcomeScreen.Parent = playerGui local welcomeMessage = Instance.new("TextLabel") welcomeMessage.Size = UDim2.new(0, 200, 0, 50) welcomeMessage.Parent = welcomeScreen welcomeMessage.Visible = false welcomeMessage.Text = "Welcome to the game!" local function onWelcomePlayerFired() welcomeMessage.Visible = true wait(3) welcomeMessage.Visible = false end welcomePlayerEvent.OnClientEvent:Connect(onWelcomePlayerFired)
right from the wiki -http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions