I have a purchase house system I have made, where the player hovers their mouse over a door, presses F2, and the house is bought, this works well in studio, unfortunately it doesn’t work at all ingame.
local buyer = plr.buyer
if buyer.Value == false then
buyer.Value = true
if plr.leaderstats.Token.Value >= script.Parent.Value.Value then
plr.leaderstats.Token.Value -= script.Parent.Value.Value
script.Parent.Parent["Buy house system"].an.SurfaceGui.SIGN.Text = plr.Name
script.Parent.Parent["Buy house system"].an.SurfaceGui.SIGN.TextColor = plr.TeamColor
script.Parent.Parent["Buy house system"].a.SurfaceGui.SIGN.Text = "Press G to sell this house."
script.Parent.Parent["Buy house system"].a.SurfaceGui.SIGN.TextColor = BrickColor.new("Deep orange")
script.Parent.Parent["Buy house system"].w.SurfaceGui.SIGN.Visible = false
script.Parent.Parent["Buy house system"].Value.Value = plr.Name
script.Parent.BUYABLE.Value = false
end
end
end)
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
user.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.F2 then
warn("You pressed ".. input.KeyCode.Name)
if mouse.Target.BUYABLE.Value == true then
local magnitude = (player.Character.HumanoidRootPart.Position - mouse.Target.Position).Magnitude
if magnitude <= 8 then
mouse.Target.Buyahouse:FireServer()
print("Distance is normal:".. magnitude)
else warn("Bad distance need not more 8 studs only distance is:"..magnitude)
end
end
end
end)
This is also another script for the system, which is in StarterPlayerScripts.