Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to change properties of my character in Studio?

Asked by 9 years ago

I have decided I will learn Lua, and today is my first day. This is also my first post.

I am going through script tutorials at the moment, I figured it would be good to go through some of these before really getting into it.

I tried to change my head's transparency in Studio Mode "Play" Mode, but whenever I try to put it in the Command Bar it tells me that "fretfatberger2" is not a part of Workspace.

EDIT: Every time I try to put in a script in Studio mode and play it or go in solo it isnt working. I tried to make a brick remove itself when it is touched, it isnt working and I cant figure it out. Here is the script I used.

function touch()
    script.Parent:remove()
end

script.Parent.Touched

3 answers

Log in to vote
0
Answered by 9 years ago

script.Parent.Touched:connect(touch) every event i think has a line called the connection line which connects it to the function

to make your head transparent you can do the following this is inside the touch function and give the touch function a parameter of hit . Hit is the part that touched script.Parent

function touch(hit)
local humanoid=hit.Parent:findFirstChild("Humanoid") 
if humanoid ~= nil then  
hit.Parent.Head.Transparency=1   
end
end

script.Parent.Touched:connect(touch)

hit.Parent.Head.Transparency=1 the Character model is the parent of the part that hit it which most likely the right or left leg Head is a child of the character and transparency is a property of head.

local humanoid=hit.Parent:findFirstChild("Humanoid") we want to make sure the object hitting script.Parent has a humanoid inside them.

0
i would suggest you watch peasfactory tutorials really easy to understand and informational. threatboy101 2 — 9y
Ad
Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

What you're missing here is something called the connection statement.

A connection statement ties a function to an event, making it so that something actually happens when the event activates - so it's essential in making something happen like when you touch a brick.

Also, the remove() method is deprecated, use the Destroy() method instead!

function touch()
    script.Parent:Destroy()
end

script.Parent.Touched:connect(touch) --connect the function 'touch'
Log in to vote
0
Answered by
funyun 958 Moderation Voter
9 years ago

Most if not all objects in Roblox have events, just like they have properties. script.Parent.Transparency is a property. script.Parent.Touched is an event. As there are different properties for different objects, there are also different events for different objects. Touched is an event specifically for parts. Upon events being triggered, you may call upon a previously declared function, in this case "touch". script.Parent.Touched:connect(touch) states that if the part is touched, call the "touch" function to destroy script.Parent.

Basically, "script.Parent.Touched" should be "script.Parent.Touched:connect(touch)".

Answer this question