(In the script stuff is called newPart and dirty rock because I’m copying the scripts from my other tycoon)
Im getting an error message, Position is not a valid member of Model “Water pistol”
I’m not sure why, I remember fixing this before in one of my other tycoons but I don’t remember how I did it.
local COOLDOWN_TIME = .2
local button = script.Parent
local tycoon = script.Parent.Parent.Parent
local dirtyRock = game.ReplicatedStorage["Water pistol"]
local dropper = script.Parent.Parent.Dropper
local objectsFolder = tycoon.Objects
local cooldown = false
local function getPlayerFromPart(part)
local character = part.Parent
if character then
local player = game.Players:GetPlayerFromCharacter(character)
return player
end
end
local function dropObject()
local newPart = dirtyRock:Clone()
newPart.Position = dropper.Position
newPart.Parent = objectsFolder
end
local function onTouched(otherPart)
if not tycoon.TycoonOwner.Value then
return
end
local player = getPlayerFromPart(otherPart)
if player then
if cooldown then
return
end
cooldown = true
button.BrickColor = BrickColor.new("Bright red")
dropObject()
wait(COOLDOWN_TIME)
cooldown = false
button.BrickColor = BrickColor.new("Bright green")
end
end
button.Touched:Connect(onTouched)