hi. Im trying to make a part with a click detector script that would spawn a part that would only be visible to the player who clicked. how would i do this?
Basically what you would need to is when ever they click the part it creates an instance of a part in a normal script.Now im not sure if that would appear on every client because one person is just clicking in the part im not sure it would make a change on the entire server.Here are the api docs you will need:ClickDetector | Roblox Creator Documentation and for instances:Instance | Roblox Creator Documentation
You could implement this on a LocalScript
inside StarterPlayerScripts
:
local Prompt = workspace.Part.ProximityPrompt
Prompt.Triggered:Connect(function()
local PlayerPart = Instance.new("Part")
PlayerPart.Size = Vector3.new(5, 5, 5)
PlayerPart.CanCollide = true
PlayerPart.Anchored = false
PlayerPart.Position = Vector3.new(25, 0, 0)
PlayerPart.Parent = workspace
print("Part made on the client")
end)
Put a LocalScript in the click detector:
local part = --define part here
script.Parent.MouseClick:Connect(function()
part.Transparency = 0
end
So in your ProximityPrompt code, fire the client using a remoteevent and this code:
remote:FireClient(Theplayerwhotrigger, PartInstanceThatGoToPlrOnlyParentedInReplicatedStorage)
Then local script:
yourremote.OnClientEvent:Connect(function(Part)
Part:Clone().Parent = Workspace.CurrentCamera
end)
Explanation: Parenting basepart or model to CurrentCamera on the client makes the part appear only to the camera user. (that plr).
If this looked a little rushed, it’s because I wrote this on my phone