im trying to make a part with a proximity prompt that when activated it make a another part appear but only locally.
i dont know how to do client sided stuff so it would be appreciated if someone could help!!
im trying to make a part with a proximity prompt that when activated it make a another part appear but only locally.
i dont know how to do client sided stuff so it would be appreciated if someone could help!!
Local scripts will run the code on that client. Local scripts need to be placed in certain instances. E.g starter player scripts, starter character scripts, startergui and a few more which I can’t remember. If you use a remote event with the local script then you can control which users see the part by firing the remote and creating the part in the local script
Sure!
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Creates a new part in ReplicatedStorage to be cloned locally. Change the properties of the part if you want.
local newPart = Instance.new("Part")
newPart.Size = Vector3.new(4, 1, 4)
newPart.Anchored = true
newPart.Name = "LocalPart"
newPart.Parent = ReplicatedStorage
-- Creates a ProximityPrompt and attach it to the parent part.
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.ActionText = "" -- Add whatever text you want here.
proximityPrompt.ObjectText = "Activate" -- Add whatever text you want here too!
proximityPrompt.Parent = script.Parent
-- The function to handle the ProximityPrompt activation.
local function onPromptTriggered(player)
-- Here, modify my code and change it to whatever you would like. These lines of code are for what the server should do when the proximity prompt is triggered.
local character = player.Character or player.CharacterAdded:Wait()
if character then
local newPart = newPart:Clone()
newPart.Parent = character
local characterCFrame = character:GetPivot()
newPart.CFrame = characterCFrame + Vector3.new(0, 5, 0)
end
end -- Thats basically it! Dont modify the code below.
-- Connect the ProximityPrompt trigger event to the function
proximityPrompt.Triggered:Connect(onPromptTriggered)
This script is for if you havent made the proximity prompt already inside the part. If you have, delete it and insert a Script inside the part that you would like to have a proximity prompt for, and then paste my script in and edit it to your liking before using it. Be aware that this script does require some editing on your behalf as I dont know what you are really trying to make.