It did work, but I’m getting the same result, it only works when the player first joins the game, then when the player resets, the proximintyprompt stays enabled.
How could you listen for when a local player is added do I do something like this?
local function onPlayerAdded(client)
if client then
onCharacterAdded(client)
end
-- Listen for the player (re)spawning
player.CharacterAdded:Connect(onCharacterAdded)
end
I’m not the best scripter I am learning from youtube tutorials and roblox dev, that’s how I even managed to get at least to this point. Sorry if I don’t fully understand everything, I am willing to learn
Thanks for the advice, but I just noticed I’m not using the “client” variable anyway for what I’m doing. It was there by mistake cause of something else I was doing. Is it actually needed for my server script to be able to work because properly because without the client variable anyway the script did work just broke once the player restarted.
Also your method was great I saw it before you took it down, but once the player restart, the other now can’t see it anymore. This is a never ending nightmare.
Sorry I went to go eat, anyways. My theory is that for whatever reason the script is referencing the old character rather than the new character that gets spawned. That’s the only thing I can think of that would match up with the errors you’re talking about. Try this and let me know how it works.
Server
local replicatedStorage = game:GetService("ReplicatedStorage")
local HideProximity = replicatedStorage:WaitForChild("HideProximity")
local Players = game:GetService("Players")
local proximityPrompt = replicatedStorage:WaitForChild("ProximityPrompt")
local function createUI(player, character)
local newProximityPromt = proximityPrompt:Clone()
newProximityPromt.Parent = character
newProximityPromt.ActionText = "Contact!"
newProximityPromt.ObjectText = character.Name
newProximityPromt.RequiresLineOfSight = false
newProximityPromt.Enabled = true
HideProximity:FireClient(player)
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
createUI(player, character)
end)
end)
Client
local player = game.Players.LocalPlayer
local function Hide()
local character = workspace:WaitForChild(player.Name)
local prox = character:WaitForChild("ProximityPrompt")
prox.Enabled = false
end
game.ReplicatedStorage.HideProximity.OnClientEvent:Connect(Hide)
THANK YOU SOO MUCH! It works like a charm, I’ll defintely look to see where I went wrong compared to your script even though I’m pretty sure like you said it was probably referring to the old proximityprompt. Still thanks a lot!