What do I want to achieve?
I want it so when the player clicks a button, the part only changes for them.
What is the issue?
The parts changes for the whole server! I need it for the local player
I have no clue what is the problem.
local Num = 0
local id = 16906874
game:GetService("Players").PlayerAdded:Connect(function(client)
client.CharacterAdded:Connect(function(character)
client.PlayerGui:WaitForChild("PartEdit").Base.Green.MouseButton1Click:Connect(function()
Num = 1
end)
client.PlayerGui:WaitForChild("PartEdit").Base.Yellow.MouseButton1Click:Connect(function()
Num = 2
end)
client.PlayerGui:WaitForChild("PartEdit").Base.Purple.MouseButton1Click:Connect(function()
Num = 0
end)
client.PlayerGui:WaitForChild("PartEdit").Base.Rainbow.MouseButton1Click:Connect(function()
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(client.UserId,id) then
Num = 3
else
game:GetService("MarketplaceService"):PromptPurchase(client, id)
end
end)
Normal scripts will change properties of your game on the server, you need to change parts of a LocalScript. But do note, LocalScripts in the workspace will not run, you need to put them in something like ReplicatedFirst or wherever else is most suitable for you.
You don’t need remote events for this. Simply put in in a local script. (Except for player added and character added, there’s no need for that, I assume that you only want to detect if the buttons are being clicked)
Basically,
And
And don’t forget to make a variable for LocalPlayer (‘client’).
I know what a RemoteEvent is lmao. What he is asking does not necessarily need that, I am simply telling him that he must put his LocalScripts somewhere other than the workspace in order for them to run.
local Num = 0
local id = 16906874
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local PlayerGui = Player:WaitForChild("PlayerGui")
local PartEdit = PlayerGui:WaitForChild("PartEdit")
Part.Edit.Base.Green.MouseButton1Click:Connect(function()
Num = 1
end)
Part.Edit.Base.Yellow.MouseButton1Click:Connect(function()
Num = 2
end)
Part.Edit.Base.Purple.MouseButton1Click:Connect(function()
Num = 0
end)
Part.Edit.Base.Rainbow.MouseButton1Click:Connect(function()
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, id) then
Num = 3
else
game:GetService("MarketplaceService"):PromptPurchase(Player, id)
end
end)
I also do recommend separating your conditional statements so that it’s a bit more organized to read