game.Players.PlayerAdded:Connect(function()
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local onlineFriends = player:GetFriendsOnline(10)
if onlineFriends == true then
script.Parent.Visible = true
wait(0.1)
game.Players.LocalPlayer.WalkSpeed = 32
game.Players.LocalPlayer.JumpPower = 100
end
end)
??
It needs to be in a localscript so first create a remote event to send a request to the server. PlayerAdded will not work on the client because the localscript runs by the time the player exists.
local players = game:GetService('Players')
local friendsOnline = players.LocalPlayer:GetFriendsOnline(200)
game:GetService('ReplicatedStorage').RemoteEventName:FireServer(friendsOnline) -- sends a request to the server
Now look at how to use the request on the server by looking at the OnServerEvent function: Custom Events and Callbacks | Documentation - Roblox Creator Hub
Edit: Just tested it so yes, it should work.
Local Script:
local players = game:GetService('Players')
local friendsOnline = players.LocalPlayer:GetFriendsOnline(200)
game:GetService('ReplicatedStorage').Friends:FireServer(friendsOnline)
Script:
game.Players.PlayerAdded:Connect(function()
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local onlineFriends = player:GetFriendsOnline(10)
if onlineFriends == true then
script.Parent.Visible = true
wait(0.1)
game.Players.LocalPlayer.WalkSpeed = 32
game.Players.LocalPlayer.JumpPower = 100
end
end)
You need to use the OnServerEvent feature (from the developer hub link I just sent you)
game:GetService('ReplicatedStorage').RemoteEventName.OnServerEvent:Connect(function(player,friendsonline)
--use the same code from the friends online script but replace the variable
end)
Make sure you inserted a remote event in replicated storage. This one should be the server script. LocalPlayer can’t be called from the server btw.
oh sure,
game:GetService('ReplicatedStorage').Friends.OnServerEvent:Connect(function(player,friendsonline)
script.Parent.Visible = true
wait(0.1)
game.Players.LocalPlayer.WalkSpeed = 3
game.Players.LocalPlayer.JumpPower = 100
end)
I thought you were gonna use the online friends script? Anyway localPlayer can’t be called from a server script. Use the “player” argument.
game:GetService('ReplicatedStorage').Friends.OnServerEvent:Connect(function(player,friendsonline)
script.Parent.Visible = true
wait(0.1)
player.Character.Humanoid.WalkSpeed = 3
player.Character.Humanoid.JumpPower = 100
end)
Edit: Use my edit sorry
Oh, nothing happens
game:GetService('ReplicatedStorage').Friends.OnServerEvent:Connect(function(player,friendsonline)
game.StarterGui.FriendLy.Amigo.Visible = true
wait(0.1)
player.Character.Humanoid.WalkSpeed = 3
player.Character.Humanoid.JumpPower = 100
end)
The StarterGui is a place where you want guis to automatically be cloned to the playergui. You need to disable the visible property in the player’s playergui not in startergui.
player.PlayerGui.Friendly.Amigo.Visible = true
Edit: I made a mistake, I didn’t do player.PlayerGui. Use this code instead.
Say “/console” and if there’s any errors show me.
add the script to serverscriptsservice not serverstorage
Look I’ll tell you something, what is supposed to be is that when the friend enters. The GUI then appears, and what happens is that if I put it Visible = true all people will see it
what do i do?, so that when the friend enters then this GUI
So you want a friend only gui? I don’t quite understand.
So when the friend is in the game with you, the GUI will appear. And that both can run fast and jump high
Use heII_ish’s method of checking if the user is your friend. If you want to check online friends use my method.