Hi, I have this script,
script.Parent.MouseButton1Click:Connect(function() character = game.Players.LocalPlayer.Character player = game.Players:GetPlayerFromCharacter(character) player.Character.Humanoid.JumpPower = 75 player.Character.Humanoid.WalkSpeed = 40 player.Character.Humanoid.SpawnTime.Value = 5 player.Backpack:ClearAllChildren() for _, _ in pairs (player.Character:GetChildren()) do if _.ClassName == ("Tool") then _:Destroy() end end game.ReplicatedStorage.Weapons.Ace["Commercia0l Airliner"]:Clone().Parent = player.Character wait(0.1) script.Parent.Parent:Destroy() end)
It's located in a local script, and I was wondering if there was a way to make a global counterpart.
The issue I'm having is that since the new version is in a global script, will all players see the effect?
Additionally, I can't seem to figure out a global alternative for "game.Players.LocalPlayer", which, in the script is what determines who clicked the gui and applies the effect to only them.
Sort of: use RemoteEvents. Here's the manual.
In this case, the local script would be the one to listen for the gui to be clicked and then fire a RemoteEvent that a server script is listening to. The server could then be responsible for lines 5-11. The server need only apply those lines to the player who activated the gui (as the first argument in the OnServerEvent
is the player who activated the event -- in this case, the player who clicked the gui).
Also, replace lines 2-3 with local player = game.Players.LocalPlayer
(you don't need to use GetPlayerFromCharacter when you just want the LocalPlayer -- that function is for the case .that you have a reference to the character model and need the player it belongs to)