local ReplicatedStorage = game:GetService("ReplicatedStorage") local Clone = ReplicatedStorage.SprintC local player = game.Players.LocalPlayer player.PlayerAdded:Connect(function() Clone:FireServer("Sprint") end)
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Clone = ReplicatedStorage.SprintC local GUI = ReplicatedStorage.Sprint:Clone() local player = game.Players.LocalPlayer Clone.OnServerEvent:Connect(function() GUI.Parent = player.PlayerGui end)
I am only using serverscripts not local scripts.
When a player joins it fires a SprintC remote and that will clone sprint from the replicatedstorage but why is it not working? Please help! Thanks in advance!
You cannot have This in a sever script.
local player = game.Players.LocalPlayer
Here's your fixed script. You only need one in StarterGUI as a localscript
local ReplicatedStorage = game:GetService("ReplicatedStorage") local GUI = ReplicatedStorage.Sprint local player = game.Players.LocalPlayer player.PlayerAdded:Connect(function() GUI:Clone().Parent = player.PlayerGui end)
If this works close this as working! if not reply, This is the only way without the script breaking on you. It works the same on what you are attempting to do, If you are just using serverscripts You're game may not get as many upvotes because of the bugs of the game
local ReplicatedStorage = game:GetService("ReplicatedStorage") local GUI = ReplicatedStorage.Sprint local player = game.Players.LocalPlayer player.PlayerAdded:Connect(function() GUI:Clone().Parent = player.PlayerGui end)
So I'd just like to add to this.
Since this might return an error, you want to yield when looking for the PlayerGui, since it needs to load into the player.
-- THIS IS JUST A CHANGE OF HeyItzscoop's SCRIPT. ALL CREDIT TO HIM.-- local ReplicatedStorage = game:GetService("ReplicatedStorage") local GUI = ReplicatedStorage.Sprint local player = game.Players.LocalPlayer player.PlayerAdded:Connect(function() GUI:Clone().Parent = player:WaitForChild("PlayerGui") -- Wait for up to 5 seconds to look for the PlayerGui "constantly" (Not really, just every ____ amount of time). end)