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.
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)
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
3 comments
Sorry, I said I wanted it so the function was like a local script in the starterpack. This would only execute the function once when the player joins. I want it so it works like it's inside the starterpack.
Ok, so you're new at this? I can give you a detailed explanation over skype.
Well not completely new anymore but yea i would appreciate an explanation please, I use discord my discord is lalelz#9877