Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone fix this script?

Asked by
Seraine 103
10 years ago

This script works in play solo, but not in server mode :L Please help I'm not sure what's wrong with it... Thanks!

script.Parent.Touched:connect(function(hit)
owned = script.Parent.Parent.Parent.Owned.Value
player = game.Players:GetPlayerFromCharacter(hit.Parent)
local found = hit.Parent:FindFirstChild("Humanoid")

if owned == false and player.Cash.Value >=1000 and player.HasHouse.Value == false then  
player.Cash.Value = player.Cash.Value-1000
player.PlayerGui.Menu.Frame.House1.Visible = true
player.HasHouse.Value = true
script.Parent.Parent.Parent.Owned.Value = true
script.Parent.Parent.Parent.OwnedBy.Value = hit.Parent.Name
script.Parent.Transparency = 1
script.Parent.CanCollide = false

else
    end
end)

1 answer

Log in to vote
3
Answered by
TofuBytes 500 Moderation Voter
10 years ago

You actually didn't test if it was a character that hit the brick. I did a through test run and set up everything, so this script should be working!

owned = script.Parent.Parent.Parent.Owned.Value

script.Parent.Touched:connect(function(hit)
    player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then --You were missing this. Then we proceed to checking if they have the requirements.
        if owned == false and player.Cash.Value >=1000 and player.HasHouse.Value == false then
            player.Cash.Value = player.Cash.Value - 1000
            player.HasHouse.Value = true
            player.PlayerGui.Menu.Frame.House1.Visible = true
            script.Parent.Parent.Parent.Owned.Value = true
            script.Parent.Parent.Parent.OwnedBy.Value = player.Name
            script.Parent.Transparency = 1
            script.Parent.CanCollide = false
        else
        print("Not enough to purchase house.")  
        end
    end
end)

Hopefully this will help you! :) Good luck!

0
My script works now, thanks for helping ! :) Seraine 103 — 10y
0
No problem! TofuBytes 500 — 10y
Ad

Answer this question