kanapuro
(kanapurottv)
November 19, 2023, 9:44pm
#1
another day another script gutted for scraps and used for my own needs
im not entirely sure why this script isnt doing the thing i told it to do :3
script.Parent.ClaimPrompt.Triggered:Connect(function(plr)
if plr.Character:WaitForChild("OwnsHouse").Value == false and script.Parent.Owner.Value == "" then
script.Parent.Owner.Value = plr.Name
script.Parent.OwnerName.SurfaceGui.TextLabel.Text = plr.Name.."'s land"
script.Parent.ClickDetector.MaxActivationDistance = 16
script.Parent.ClaimPrompt.ActionText = "Unclaim"
plr.Character:WaitForChild("OwnsHouse").Value = true
end
end)
script.Parent.ClaimPrompt.Triggered:Connect(function(plr)
if script.Parent.Owner.Value == plr.Name then
script.Parent.Owner.Value = ""
script.Parent.ClickDetector.MaxActivationDistance = 0
script.Parent.OwnerName.SurfaceGui.TextLabel.Text = "unowned land"
script.Parent.ClaimPrompt.ActionText = "Claim"
plr.Character:WaitForChild("OwnsHouse").Value = false
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
if script.Parent.Owner.Value == plr.Name then
script.Parent.Owner.Value = ""
script.Parent.ClickDetector.MaxActivationDistance = 0
script.Parent.OwnerName.SurfaceGui.TextLabel.Text = "unowned land"
script.Parent.ClaimPrompt.ActionText = "Claim"
end
end)
it’s likely something very obvious but i just cant see it LOL
Katrist
(Katrist)
November 19, 2023, 9:48pm
#2
Probably because both functions run after another, so when you set the owner text to “”, the other script thinks that there wasn’t an owner in the first place and sets you back to the owner.
Code:
script.Parent.ClaimPrompt.Triggered:Connect(function(plr)
if script.Parent.Owner.Value == plr.UserId then
script.Parent.Owner.Value = ""
script.Parent.ClickDetector.MaxActivationDistance = 0
script.Parent.OwnerName.SurfaceGui.TextLabel.Text = "unowned land"
script.Parent.ClaimPrompt.ActionText = "Claim"
plr.Character:WaitForChild("OwnsHouse").Value = false
elseif plr.Character:WaitForChild("OwnsHouse").Value == false and script.Parent.Owner.Value == "" then
script.Parent.Owner.Value = plr.UserId
script.Parent.OwnerName.SurfaceGui.TextLabel.Text = plr.Name.."'s land"
script.Parent.ClickDetector.MaxActivationDistance = 16
script.Parent.ClaimPrompt.ActionText = "Unclaim"
plr.Character:WaitForChild("OwnsHouse").Value = true
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
if script.Parent.Owner.Value == plr.UserId then
script.Parent.Owner.Value = ""
script.Parent.ClickDetector.MaxActivationDistance = 0
script.Parent.OwnerName.SurfaceGui.TextLabel.Text = "unowned land"
script.Parent.ClaimPrompt.ActionText = "Claim"
end
end)
I would also be logging the owners via UserId, not their name because that can be changed.
1 Like
kanapuro
(kanapurottv)
November 19, 2023, 9:50pm
#3
Yo thanks! Perfect fix!! I hadn’t realized it functioned like that lol
1 Like
kanapuro
(kanapurottv)
November 19, 2023, 11:10pm
#4
For some reason this stopped functioning and I don’t know why, so I’m reopening this subject
Katrist
(Katrist)
November 19, 2023, 11:17pm
#5
You’re using the exact same script as earlier and it just stopped working?
Do you use that .Owner value anywhere else?
1 Like
kanapuro
(kanapurottv)
November 19, 2023, 11:22pm
#6
Yes I’m using the exact script you wrote for me, and “Owner” doesn’t seem to exist anywhere else. I’m not quite sure why it simply stopped working.
Katrist
(Katrist)
November 19, 2023, 11:26pm
#7
What doesn’t “work” about it?
1 Like
kanapuro
(kanapurottv)
November 19, 2023, 11:28pm
#8
As in you can’t remove ownership using the unclaim button, just like the original issue. I’m not quite sure why.
Katrist
(Katrist)
November 19, 2023, 11:31pm
#9
Tell me what this prints:
script.Parent.ClaimPrompt.Triggered:Connect(function(plr)
print(plr.UserId)
print(script.Parent.Owner.Value)
if script.Parent.Owner.Value == plr.UserId then
script.Parent.Owner.Value = ""
script.Parent.ClickDetector.MaxActivationDistance = 0
script.Parent.OwnerName.SurfaceGui.TextLabel.Text = "unowned land"
script.Parent.ClaimPrompt.ActionText = "Claim"
plr.Character:WaitForChild("OwnsHouse").Value = false
elseif plr.Character:WaitForChild("OwnsHouse").Value == false and script.Parent.Owner.Value == "" then
script.Parent.Owner.Value = plr.UserId
script.Parent.OwnerName.SurfaceGui.TextLabel.Text = plr.Name.."'s land"
script.Parent.ClickDetector.MaxActivationDistance = 16
script.Parent.ClaimPrompt.ActionText = "Unclaim"
plr.Character:WaitForChild("OwnsHouse").Value = true
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
if script.Parent.Owner.Value == plr.UserId then
script.Parent.Owner.Value = ""
script.Parent.ClickDetector.MaxActivationDistance = 0
script.Parent.OwnerName.SurfaceGui.TextLabel.Text = "unowned land"
script.Parent.ClaimPrompt.ActionText = "Claim"
end
end)
1 Like
kanapuro
(kanapurottv)
November 19, 2023, 11:33pm
#10
Prints from claiming and trying to unclaim:
Katrist
(Katrist)
November 19, 2023, 11:33pm
#11
Do you use OwnsHouse anywhere else?
1 Like
kanapuro
(kanapurottv)
November 19, 2023, 11:35pm
#12
This is the only other script the build uses (just to open and close the door).
local frame = script.Parent
local clickDetector = frame:WaitForChild("ClickDetector")
local opened = frame.Parent:WaitForChild("Opened")
local debounce = true
clickDetector.MouseClick:Connect(function()
if debounce == true then
debounce = false
if opened.Value == true then
opened.Value = false
frame.Transparency = 0
frame.CanCollide = true
else
opened.Value = true
frame.Transparency = 0.5
frame.CanCollide = false
end
wait(0.35)
debounce = true
end
end)
The player morph (in ServerScriptService) has the OwnsHouse value, and there are no other mentions of Owner or Ownshouse anywhere else in the game.
Katrist
(Katrist)
November 19, 2023, 11:37pm
#13
The bug could be because when you reset, you don’t set the OwnsHouse value back to true.
Code:
local Players = game:GetService("Players")
local DoorFrame = script.Parent
DoorFrame.ClaimPrompt.Triggered:Connect(function(plr)
print(plr.UserId)
print(DoorFrame.Owner.Value)
if DoorFrame.Owner.Value == plr.UserId then
DoorFrame.Owner.Value = ""
DoorFrame.ClickDetector.MaxActivationDistance = 0
DoorFrame.OwnerName.SurfaceGui.TextLabel.Text = "unowned land"
DoorFrame.ClaimPrompt.ActionText = "Claim"
plr:SetAttribute("OwnsHouse", false)
elseif not plr:GetAttribute("OwnsHouse") and DoorFrame.Owner.Value == "" then
DoorFrame.Owner.Value = plr.UserId
DoorFrame.OwnerName.SurfaceGui.TextLabel.Text = plr.Name.."'s land"
DoorFrame.ClickDetector.MaxActivationDistance = 16
DoorFrame.ClaimPrompt.ActionText = "Unclaim"
plr:SetAttribute("OwnsHouse", true)
end
end)
Players.PlayerRemoving:Connect(function(plr)
if DoorFrame.Owner.Value == plr.UserId then
DoorFrame.Owner.Value = ""
DoorFrame.ClickDetector.MaxActivationDistance = 0
DoorFrame.OwnerName.SurfaceGui.TextLabel.Text = "unowned land"
DoorFrame.ClaimPrompt.ActionText = "Claim"
end
end)
1 Like
kanapuro
(kanapurottv)
November 19, 2023, 11:39pm
#14
Yeah this script didn’t change anything either