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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Help with Morph script

Previous Thread :: Next Thread 
usermvp is not online. usermvp
Joined: 29 Jun 2013
Total Posts: 188
07 Feb 2016 03:06 PM
So, what the morph script does is gives the player a sword and removes 2 other swords, Steel Sword and Gold Sword, but only if the swords are there. The problem is sometimes the swords won't change and then once they stop changing they won't change anymore.

Script:

script.Parent.Touched:connect(onTouch)

debounce = false

function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end

function onTouch(part)

local human = part.Parent:findFirstChild("Humanoid")
if (human == nil) then return end

local player = getPlayer(human)

if (player == nil) then return end

if not debounce then

debounce = true

-- Remove any other swords the player might have

local checkforsteelsword = player:FindFirstChild("Backpack"):FindFirstChild("Steel Sword")
if checkforsteelsword ~= nil then
checkforsteelsword:remove()
end

local checkforgoldsword = player:FindFirstChild("Backpack"):FindFirstChild("Gold Sword")
if checkforgoldsword ~= nil then
checkforgoldsword:remove()
end

local checkforwoodsword = player:FindFirstChild("Backpack"):FindFirstChild("Wood Sword")
if checkforwoodsword == nil then
print("No wood sword")
game.ReplicatedStorage:findFirstChild("Wood Sword"):clone().Parent = player.Backpack
script.Disabled = true
wait(0.5)
script.Disabled = false
elseif checkforwoodsword then
print("Wood sword found")
end

wait(0.5)

debounce = true

end
end
script.Parent.Touched:connect(onTouch)

Report Abuse
tapuzi is not online. tapuzi
Joined: 05 Jul 2014
Total Posts: 162
07 Feb 2016 03:56 PM

try making the parent of the sword = nil
(the ones you want to remove)
also
Remove() is deprecated in favor of Destroy and ClearAllChildren

As it stands your script wont necessarily report the presence of a wooden sword IF one has just been added as the elseif would be out of scope in that circumstance.

i have doubts about calling script.Disabled from within a script - I don't think it works, probably not a good idea to have a wait() inside an if then elseif structure.

hope this helps
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