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

How to you make a part that changes your size on touch?

Asked by
3wdo 198
5 years ago

So in my game its supposed to be a family game i'm trying to make a part that changes your size like the one in meepcity. Can someone help me? Here is my script and sorry if your a good scripter and think its stupid.I'm still a beginner at scripting and btw i got a script from somewhere and it made my character either fall or lean back when walking so please make sure it dont do that

script:

script.Parent.Touched:connect(function(part)
   game.Players.LocalPlayer.Character.Humanoid.BodyHeightScale.Value = 0.5
end)
0
ok I will help wait a sec RetroGalacticGamer 331 — 5y
0
Alberto, is your game in r15? Mr_Unlucky 1085 — 5y
0
yeah its R15 3wdo 198 — 5y
0
Thanks for excepting my answer, I hope if gives you a good understanding of the problem! RetroGalacticGamer 331 — 5y
0
ewwww use Connect LoganboyInCO 150 — 5y

3 answers

Log in to vote
-2
Answered by 5 years ago
Edited 5 years ago
Script.Parent.Touched:Connect(function(hit)
        If hit.Parent:FindFirstChild(“Humanoid”) then
        game.Workspace[hit.Parent.Name].Humanoid.BodyHeightScale.Value = 0.5
end)

Expiation: In the ruction a have made a variable called hit, so whenever I reference hit it means the thing that was touched. After this I have checked the Parent of the hit to see if it’s a humanoid. After that I went into the workspace and located the character, lowering its height.

I did this on a mobile device so I can not test it.

Also you can only use the local player statement in a local script.

Also make sure this is a sever script.

If you need anymore help just ask.

Also DO NOT ever take scripts from other people, you won’t learn anything!

0
Sorry to say but it didn't work 3wdo 198 — 5y
0
Is it in a server script? retrobricks 162 — 5y
0
And was there a error? retrobricks 162 — 5y
0
Also make sure the script is a part retrobricks 162 — 5y
View all comments (19 more)
0
Also make sure the script is a part retrobricks 162 — 5y
0
OH i didnt see you say server script 3wdo 198 — 5y
0
Does it work? retrobricks 162 — 5y
0
"Also make sure the script is a part" ok but how do you do that 3wdo 198 — 5y
0
Drag the script into the part is wanted to be touched retrobricks 162 — 5y
0
oh i knew that but the way you said it didn't make sense to me 3wdo 198 — 5y
0
Please do more research in scripting, your lucky that mods have not taken down your question on how easy it is. retrobricks 162 — 5y
0
Try looking at this https://wiki.roblox.com/index.php?title=Developer_Resources then if you can’t work it out then ask a question. retrobricks 162 — 5y
0
"Is it in server script?" i did but how do i know if i touched the brick because it disapears when i put it in server script service 3wdo 198 — 5y
0
Sigh* you create a server script and then put it in a part retrobricks 162 — 5y
0
A server script is the one with nothing on it, it’s just blue retrobricks 162 — 5y
0
Here's some problems, you forgot to put an "end" at the conditional statement. "If" shouldn't be capitalized and instead lower-case like "if". You didn't indent it properly either. Mr_Unlucky 1085 — 5y
0
She doesn’t understand what I server script is, she’s getting confused retrobricks 162 — 5y
0
Also I did this on an iPad. retrobricks 162 — 5y
0
Thank you it works now 3wdo 198 — 5y
0
i know what server script service is i made a leaderboard script in it but its from alvin blox and a video didnt show what i wanted but a size change 3wdo 198 — 5y
0
No problem, I just recommend doing some more research and messing around with studio to get comfortable with the platform retrobricks 162 — 5y
0
ok 3wdo 198 — 5y
0
hey? you didnt see my answer? RetroGalacticGamer 331 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Ok, so first off, I see that you are using the object LocalPlayer in your script. Since you can only access it in a LocalScript, I am going to assume you are using a LocalScript. This is a big problem (if you are using a LocalScript), because if you use a LocalScript to operate your body scaling content for your game, it will only show the person who touches the part scaled, and others will see them as the size they used to be before they touched the part. This is because anything done in LocalScripts (except for a few exceptions like animations) will not be replicated to the server, at least not properly or in the right way. So here is some advice: Use a ServerScript. That way, it will replicate to all players, not just one player. Another thing is your code is just simply not correct. If you look at the touched event, the part parameter is not being used. Lowercase Connect is also deprecated, you need to be using capitalized Connect. It may not seem like a big deal, but it is. One more thing is that line 2 is not the right way to be scaling the player in a touched event. I will show you a better method. So, this method requires the parameter you put in your function earlier but did not use. This part involves the actual fixing of your code. So, you did use a touched event. That is correct. The code in your touched event was not correct.

So, lets think about the parameter for a moment. As it says on the Roblox Developer Hub, there is a parameter called "OtherPart". If the character's body parts are the ones touching the Basepart, then we reference their entire body and find their humanoid, which we can then scale their body from. So, this is the code:

local BasePart = script.Parent

function Scale(otherPart)
    local Character = otherPart.Parent --otherPart will be player's body part that touches
    local Humanoid = Character:FindFirstChild("Humanoid")
    if Humanoid then --checks if humanoid exists
        local HeightScale = Humanoid:FindFirstChild("BodyHeightScale")
        HeightScale.Value = 0.5
    end
end

BasePart.Touched:Connect(Scale)

This should work. I might have forgot to add something, but other than that it should would. Accept this answer if this helps!

0
crap I took too long RetroGalacticGamer 331 — 5y
0
I wasted all that time RetroGalacticGamer 331 — 5y
0
oh thank you! RetroGalacticGamer 331 — 5y
0
Worked 3wdo 198 — 5y
Log in to vote
0
Answered by
QsDoes 0
5 years ago

script.Parent.Touched:Connect(function() script.Parent.Size = Vector3.new(x,y,z) wait(2) script.Parent.Size = Vector3.new(x,y,z) end)

Answer this question