Panwellz
|
  |
| Joined: 16 Oct 2012 |
| Total Posts: 749 |
|
|
| 20 Jan 2016 03:25 PM |
Im trying to convert this script from function on touch to function on click: factory = script.Parent.Parent.Parent local ting = 0 Upgradecost = script.Parent.Parent.Value.Value
function onTouched(hit) if ting == 0 then ting = 1
local h = hit.Parent:FindFirstChild("Humanoid") check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then local user = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = user:findFirstChild("leaderstats") local space = user:findFirstChild("Vehicles") if (h ~= nil ) then if game:GetService("BadgeService"):UserHasBadge(game.Players[h.Parent.Name].userId, script.Parent.BadgeID.Value) ~= false then
if stats ~= nil then local cash = stats:findFirstChild("Money")
if cash.Value > (Upgradecost-1) then
if space.Value == 0 then space.Value = 1 cash.Value = cash.Value - Upgradecost script.Parent.Parent.Pad1.CanCollide = true script.Parent.Parent.Pad2.CanCollide = true machine = factory.Stuff.ChevelleS2.Value:Clone() machine.Parent = h machine:MakeJoints() msg = Instance.new("Message") msg.Parent = user:findFirstChild("PlayerGui") msg.Text = "message" script.Parent.BrickColor = BrickColor.new("Black") script.Parent.Transparency = 0.5 wait(1.5) script.Parent.Parent.Pad1.CanCollide = false script.Parent.Parent.Pad2.CanCollide = false msg:remove() script.Parent.Transparency = 0 wait(1.5) script.Parent.BrickColor = BrickColor.new("Royal purple")
else msg = Instance.new("Message") msg.Parent = user:findFirstChild("PlayerGui") msg.Text = "You already own a vehicle." wait(2) msg:remove() end
else msg = Instance.new("Message") msg.Parent = user:findFirstChild("PlayerGui") msg.Text = "You do not have enough money." wait(2) msg:remove() end
end
else msg = Instance.new("Message") msg.Parent = user:findFirstChild("PlayerGui") msg.Text = "This vehicle requires VIP." wait(2) msg:remove() end
else msg = Instance.new("Message") msg.Parent = user:findFirstChild("PlayerGui") msg.Text = "This vehicle requires VIP." wait(2) msg:remove() end end
ting = 0 end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2016 03:27 PM |
try this
factory = script.Parent.Parent.Parent local ting = 0 Upgradecost = script.Parent.Parent.Value.Value
script.Parent.ClickDetector.MouseClick(function(hit) if ting == 0 then ting = 1
local h = hit.Parent:FindFirstChild("Humanoid") check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then local user = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = user:findFirstChild("leaderstats") local space = user:findFirstChild("Vehicles") if (h ~= nil ) then if game:GetService("BadgeService"):UserHasBadge(game.Players[h.Parent.Name].userId, script.Parent.BadgeID.Value) ~= false then
if stats ~= nil then local cash = stats:findFirstChild("Money")
if cash.Value > (Upgradecost-1) then
if space.Value == 0 then space.Value = 1 cash.Value = cash.Value - Upgradecost script.Parent.Parent.Pad1.CanCollide = true script.Parent.Parent.Pad2.CanCollide = true machine = factory.Stuff.ChevelleS2.Value:Clone() machine.Parent = h machine:MakeJoints() msg = Instance.new("Message") msg.Parent = user:findFirstChild("PlayerGui") msg.Text = "message" script.Parent.BrickColor = BrickColor.new("Black") script.Parent.Transparency = 0.5 wait(1.5) script.Parent.Parent.Pad1.CanCollide = false script.Parent.Parent.Pad2.CanCollide = false msg:remove() script.Parent.Transparency = 0 wait(1.5) script.Parent.BrickColor = BrickColor.new("Royal purple")
else msg = Instance.new("Message") msg.Parent = user:findFirstChild("PlayerGui") msg.Text = "You already own a vehicle." wait(2) msg:remove() end
else msg = Instance.new("Message") msg.Parent = user:findFirstChild("PlayerGui") msg.Text = "You do not have enough money." wait(2) msg:remove() end
end
else msg = Instance.new("Message") msg.Parent = user:findFirstChild("PlayerGui") msg.Text = "This vehicle requires VIP." wait(2) msg:remove() end
else msg = Instance.new("Message") msg.Parent = user:findFirstChild("PlayerGui") msg.Text = "This vehicle requires VIP." wait(2) msg:remove() end end
ting = 0 end end) |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2016 03:33 PM |
Change this
script.Parent.Touched:connect(onTouched)
to
script.Parent.MouseClick:connect(onTouched)
And put a ClickDetector in the brick and put the script in the ClickDetector |
|
|
| Report Abuse |
|
|
Panwellz
|
  |
| Joined: 16 Oct 2012 |
| Total Posts: 749 |
|
|
| 20 Jan 2016 03:46 PM |
| thx, i think i messed up the function connect when i did it. |
|
|
| Report Abuse |
|
|