Hello, this script manages the owner of a sign however when the sign is claimed anyone can edit the text on it and the edit proximity prompt shows up for everyone. Any help is appreciated.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local EditEvent = ReplicatedStorage.Events:FindFirstChild("EditEvent")
local Sign = script.Parent.Parent
local ClaimPrompt = Sign.Structure.Prompt:FindFirstChild("Claim")
local EditPrompt = Sign.Structure.Prompt:FindFirstChild("Edit")
local OwnerText = Sign.Structure.Signs.OwnerSign.SurfaceGui:FindFirstChild("Owner")
local OwnerValue = Sign.Values:FindFirstChild("Owner")
ClaimPrompt.Triggered:Connect(function(Player)
if Player.Character:FindFirstChild("Humanoid") and OwnerValue.Value == nil then
ClaimPrompt.Enabled = false
OwnerValue.Value = Player
OwnerText.Text = tostring(OwnerValue.Value).."'s Sign!"
EditPrompt.Enabled = true
end
end)
EditPrompt.Triggered:Connect(function(Player)
if Player.Character:FindFirstChild("Humanoid") and OwnerValue.Value ~= Player.Name then
EditPrompt.Enabled = false
EditEvent:FireClient(Player)
end
end)
What @vParkuu said. Your script should look like this to fit ObjectValues.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local EditEvent = ReplicatedStorage.Events:FindFirstChild("EditEvent")
local Sign = script.Parent.Parent
local ClaimPrompt = Sign.Structure.Prompt:FindFirstChild("Claim")
local EditPrompt = Sign.Structure.Prompt:FindFirstChild("Edit")
local OwnerText = Sign.Structure.Signs.OwnerSign.SurfaceGui:FindFirstChild("Owner")
local OwnerValue = Sign.Values:FindFirstChild("Owner")
ClaimPrompt.Triggered:Connect(function(Player)
if Player.Character:FindFirstChild("Humanoid") and OwnerValue.Value == nil then
ClaimPrompt.Enabled = false
OwnerValue.Value = Player
OwnerText.Text = tostring(OwnerValue.Value.Name).."'s Sign!"
EditPrompt.Enabled = true
end
end)
EditPrompt.Triggered:Connect(function(Player)
if Player.Character:FindFirstChild("Humanoid") and OwnerValue.Value ~= Player then
EditPrompt.Enabled = false
EditEvent:FireClient(Player)
end
end)