Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is this script correct? (I have no confidence in it being correct)

Okay. So this script is supposed to save what houses the player has bought and make it so that they are still usable by the player after the player has left the game and returned. I am not at all confident in the script being correct and I don't want to waste hours earning the money to buy the house in my game only to see that the script didn't work. Here is the script:

local plr = game.Players.LocalPlayer
local washousePurchased = false
local uniquekey = 'id-'..plr.UserID

if script.Parent.MouseClick and plr.leaderstats.Money.Value >= 150 then --if the clickdetector that is the script's parent got clicked while the player's money value was 150 or up, the house was automatically purchased, so essentially this is just seeing if the house was bought
	washousePurchased = true --purchasing the house makes the value true
	if washousePurchased == true then
		game.Players.PlayerAdded:connect(function()
			game.Workspace["Uncommon House"].Door.CanCollide = false --makes the house's door's cancollide value false so that the person who bought it can get in
		end)
	end
end
--i bet i made 1000 different errors here, don't make fun of me i am a total scripting nub :P

1 comment

0

I'm no perfect raspberry pudding but something caught my eye immediately. LocalPlayer is a local script variable and mouseClick is server script to use this one instead.

1 answer

Try this script if it isn't working.

game.Players.PlayerAdded:connect(function(plr)
    local washousePurchased = false
    local uniquekey = 'id-'..plr.UserID
    if script.Parent.MouseClick and plr.leaderstats.Money.Value >= 150 then 
        washousePurchased = true 
        if washousePurchased == true then
                game.Workspace["Uncommon House"].Door.CanCollide = false
        end
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.