generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

how do i convert touch brick script into click brick script?

Previous Thread :: Next Thread 
Panwellz is not online. 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
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
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
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image