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

Why won't this scrolling frame scroll on KeyDown?

Asked by 10 years ago

I am making something for a game, and for some reason, the script returns with no errors, but it does nothing. I have tried scrolling it all the way, finding the position, and scrolling it back. Nothing will work for me. It is supposed to be when you hit a button, it will scroll a 4th of the way in either direction, and change the tool value.

I have pictures here of what it looks like: In game: http://imgur.com/vWce8yc,8CUxw25 In the explorer: http://imgur.com/vWce8yc,8CUxw25#1

Here is the code:

game.StarterGui:SetCoreGuiEnabled(4, false)
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()

Size = script.Parent.AbsoluteWindowSize
Rsize = Size/4

Mouse.KeyDown:connect(function(key)
    if key == "e" then
        for Scroll = 1,5 do
        script.Parent.CanvasPosition = script.Parent.CanvasPosition +Vector2.new(Rsize, 0)
        end
        if script.Parent.SelectedTool.Value ~= 4 then
            script.Parent.SelectedTool.Value =  script.Parent.SelectedTool.Value +1
        end
    end
end)
Mouse.KeyDown:connect(function(key)
    if key == "q" then
        for Scroll = 1,5 do
        script.Parent.CanvasPosition = script.Parent.CanvasPosition -Vector2.new(Rsize, 0)
        end 
        if script.Parent.SelectedTool.Value ~= 1 then
            script.Parent.SelectedTool.Value =  script.Parent.SelectedTool.Value -1
        end
    end
end)

1 answer

Log in to vote
1
Answered by 10 years ago

I just basically copied this from the Roblox wiki lesson. Here's the code to this or link

-- In a LocalScript in StarterGui:

-- Create ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = script.Parent

-- Create ScrollingFrame
local scrollingFrame = Instance.new("ScrollingFrame")
scrollingFrame.Parent = screenGui
scrollingFrame.Position = UDim2.new(0.2, 0, 0.1, 0)
scrollingFrame.Size = UDim2.new(0, 200, 0, 100)
scrollingFrame.CanvasSize = UDim2.new(0, 600, 2, 0)
scrollingFrame.BackgroundColor3 = BrickColor.White().Color
scrollingFrame.BottomImage = "rbxassetid://156476249"
scrollingFrame.MidImage = "rbxassetid://156476256"
scrollingFrame.TopImage = "rbxassetid://156476261"

-- Create images to put in ScrollingFrame
local topLeftImage = Instance.new("ImageLabel")
topLeftImage.Parent = scrollingFrame
topLeftImage.Position = UDim2.new(0, 0, 0, 0)
topLeftImage.Size = UDim2.new(0, 100, 0, 100)
topLeftImage.BackgroundColor3 = Color3.new(255/255, 162/255, 116/255)
topLeftImage.ZIndex = 2
topLeftImage.ImageTransparency = 0.5
topLeftImage.Image = "rbxassetid://133293265"

local topRightImage = Instance.new("ImageLabel")
topRightImage.Parent = scrollingFrame
topRightImage.Position = UDim2.new(1, -100, 0, 0)
topRightImage.Size = UDim2.new(0, 100, 0, 100)
topRightImage.BackgroundColor3 = Color3.new(255/255, 190/255, 216/255)
topRightImage.ZIndex = 2
topRightImage.ImageTransparency = 0.5
topRightImage.Image = "rbxassetid://133293265"

local bottomLeftImage = Instance.new("ImageLabel")
bottomLeftImage.Parent = scrollingFrame
bottomLeftImage.Position = UDim2.new(0, 0, 1, -100)
bottomLeftImage.Size = UDim2.new(0, 100, 0, 100)
bottomLeftImage.BackgroundColor3 = Color3.new(28/255, 255/255, 180/255)
bottomLeftImage.ZIndex = 2
bottomLeftImage.ImageTransparency = 0.5
bottomLeftImage.Image = "rbxassetid://133293265"

local bottomRightImage = Instance.new("ImageLabel")
bottomRightImage.Parent = scrollingFrame
bottomRightImage.Position = UDim2.new(1, -100, 1, -100)
bottomRightImage.Size = UDim2.new(0, 100, 0, 100)
bottomRightImage.BackgroundColor3 = Color3.new(28/255, 69/255, 255/255)
bottomRightImage.ZIndex = 2
bottomRightImage.ImageTransparency = 0.5
bottomRightImage.Image = "rbxassetid://133293265"

http://wiki.roblox.com/index.php?title=Scrolling_Frame_Tutorial

0
You misunderstood. I need the position of the frame to move when someone hits a key. I need a way to do that. MisaMiner 50 — 10y
0
well look on this page to help you :) GreekGodOfMLG 244 — 10y
Ad

Answer this question