As said in the comments, you need to use a Remote Event. I'll give you a quick explanation on what those are.
Well, first we need to start off with local scripts. Local scripts only run on the client, or your side of the game. So any code you try to run in a local script will only effect your screen. This is why the script seems to work, but only for you.
However, that's where Remote Events come in. Basically what they do is run code in a server script when activated from a local script. They can also communicate the reversed way, server running code in a local script, but this isn't important at the moment.
I will provide a basic example of using a Remote Event:
Insert a RemoteEvent into ReplicatedStorage, leaving it at its default name, RemoteEvent.
local Plr = game.Players.LocalPlayer
local Mou = Plr:GetMouse()
local RS = game:GetService("ReplicatedStorage")
Mou.Button1Down:Connect(function()
RS.RemoteEvent:FireServer()
end)
local RS = game:GetService("ReplicatedStorage")
RS.RemoteEvent.OnServerEvent:Connect(function()
local Part = Instance.new("Part")
Part.Parent = workspace
end)
Finished, now you successfully made it so whenever the player clicks, a part is created in workspace that replicates to the server. Now all you have to do is incorporate this concept into your script if you are trying to make server changes via local script.
4 comments
use remote events
Watch this video on remote events https://www.youtube.com/watch?v=wic-N4JiFss&t=771s.
I've already given you an example of this, have you not looked at my previous answer?
Hm, judging by the changes you have, and decided to pretend you didn't. That's just mean